| @@ -1,169 +1,472 @@ | ||
| 1 | -<?php echo logtivity_view('_admin-header'); ?> | |
| 1 | +<?php | |
| 2 | 2 | |
| 3 | -<div class="postbox"> | |
| 4 | - <div class="inside logtivity-settings"> | |
| 3 | +/** | |
| 4 | + * @package Logtivity | |
| 5 | + * @contact logtivity.io, [email protected] | |
| 6 | + * @copyright 2024-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 | + */ | |
| 5 | 24 | |
| 6 | - <h1 style="padding-top: 20px;">Settings</h1> | |
| 25 | +/** | |
| 26 | + * @var string $fileName | |
| 27 | + * @var array $vars | |
| 28 | + * @var array $value | |
| 29 | + * @var string $key | |
| 30 | + * @var array $options | |
| 31 | + */ | |
| 7 | 32 | |
| 8 | - <form action="<?php echo admin_url( 'admin-ajax.php' ); ?>?action=logtivity_update_settings" method="post"> | |
| 33 | +$api = new Logtivity_Api(); | |
| 34 | +$apiKey = $api->getApiKey(); | |
| 35 | +$connectionStatus = $api->getConnectionStatus(); | |
| 36 | +$debugLogEntries = (new Logtivity_Debug_Log())->recent(); | |
| 9 | 37 | |
| 10 | - <?php wp_nonce_field( 'logtivity_update_settings', 'logtivity_update_settings' ) ?> | |
| 38 | +// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- logtivity_view() renders trusted plugin templates. | |
| 39 | +echo logtivity_view('_admin-header', compact('options')); | |
| 40 | +?> | |
| 11 | 41 | |
| 12 | - <table class="form-table"> | |
| 13 | - <tbody> | |
| 14 | - <tr class="user-user-login-wrap"> | |
| 15 | - <th> | |
| 16 | - <label for="logtivity_site_api_key">Site API Key</label> | |
| 17 | - <?php if (has_filter('logtivity_site_api_key')): ?> | |
| 18 | - <div class="logtivity-constant">This option has been set in code.</div> | |
| 19 | - <?php endif ?> | |
| 20 | - </th> | |
| 21 | - <td> | |
| 22 | - <input <?php echo ( has_filter('logtivity_site_api_key') ? 'readonly' : ''); ?> type="text" name="logtivity_site_api_key" id="logtivity_site_api_key" value="<?php echo sanitize_text_field($options['logtivity_site_api_key']); ?>" class="regular-text"> | |
| 23 | - <?php if ($options['logtivity_api_key_check']): ?> | |
| 24 | - <p>Status: <?php echo ( sanitize_text_field($options['logtivity_api_key_check']) != 'fail' ? '<span style="color: #4caf50; font-weight: bold;">Connected</span>' : '<span style="color: #ff3232; font-weight: bold;">Not connected. Please check API key.</span>'); ?></p> | |
| 25 | - <?php endif ?> | |
| 26 | - </td> | |
| 27 | - <td> | |
| 28 | - <span class="description">You can find this value by logging into your account and navigating to/creating this site settings page.</span> | |
| 29 | - </td> | |
| 30 | - </tr> | |
| 31 | - <tr class="user-user-login-wrap"> | |
| 32 | - <th> | |
| 33 | - <label for="logtivity_disable_default_logging">Disable built in Event Logging.</label> | |
| 34 | - <?php if (has_filter('logtivity_disable_default_logging')): ?> | |
| 35 | - <div class="logtivity-constant">This option has been set in code.</div> | |
| 36 | - <?php endif ?> | |
| 37 | - </th> | |
| 38 | - <td> | |
| 39 | - <input type="hidden" name="logtivity_disable_default_logging" id="logtivity_disable_default_logging" value="0"> | |
| 42 | +<div class="postbox logtivity-settings"> | |
| 43 | + <div class="inside"> | |
| 44 | + <h1 style="padding-top: 20px;">Settings</h1> | |
| 40 | 45 | |
| 41 | - <input <?php echo ( has_filter('logtivity_disable_default_logging') ? 'readonly' : ''); ?> type="checkbox" name="logtivity_disable_default_logging" id="logtivity_disable_default_logging" value="1" class="regular-checkbox" <?php echo ( absint($options['logtivity_disable_default_logging']) ? 'checked' : ''); ?>> | |
| 42 | - </td> | |
| 43 | - <td> | |
| 44 | - <span class="description">Check this box if you do not want the plugin to log actions automatically and you would prefer to manually log specific actions with code.</span> | |
| 45 | - </td> | |
| 46 | - </tr> | |
| 47 | - <tr class="user-user-login-wrap"> | |
| 48 | - <th> | |
| 49 | - <label for="logtivity_should_store_user_id">Store User ID</label> | |
| 50 | - <?php if (has_filter('logtivity_should_store_user_id')): ?> | |
| 51 | - <div class="logtivity-constant">This option has been set in code.</div> | |
| 52 | - <?php endif ?> | |
| 53 | - </th> | |
| 54 | - <td> | |
| 55 | - <input type="hidden" name="logtivity_should_store_user_id" id="logtivity_should_store_user_id" value="0"> | |
| 46 | + <?php if (logtivity_has_site_url_changed()): ?> | |
| 47 | + <div class="logtivity-notice logtivity-notice-danger"> | |
| 48 | + <h2>We've detected a change in your site URL.</h2> | |
| 49 | + <div> | |
| 50 | + As a precaution, we've stopped logging. To start recording | |
| 51 | + logs, again click the 'Update Settings' button below. | |
| 52 | + </div> | |
| 53 | + </div> | |
| 54 | + <?php endif; | |
| 56 | 55 | |
| 57 | - <input <?php echo ( has_filter('logtivity_should_store_user_id') ? 'readonly' : ''); ?> type="checkbox" name="logtivity_should_store_user_id" id="logtivity_should_store_user_id" value="1" class="regular-checkbox" <?php echo ( absint($options['logtivity_should_store_user_id']) ? 'checked' : ''); ?>> | |
| 58 | - </td> | |
| 59 | - <td> | |
| 60 | - <span class="description">If you check this box, when logging an action, we will include the users User ID in the logged action.</span> | |
| 61 | - </td> | |
| 62 | - </tr> | |
| 63 | - <tr class="user-user-login-wrap"> | |
| 64 | - <th> | |
| 65 | - <label for="logtivity_should_log_profile_link">Store Users Profile Link</label> | |
| 66 | - <?php if (has_filter('logtivity_should_log_profile_link')): ?> | |
| 67 | - <div class="logtivity-constant">This option has been set in code.</div> | |
| 68 | - <?php endif ?> | |
| 69 | - </th> | |
| 70 | - <td> | |
| 71 | - <input type="hidden" name="logtivity_should_log_profile_link" id="logtivity_should_log_profile_link" value="0"> | |
| 56 | + if (logtivity_url_environment_mismatch()) : ?> | |
| 57 | + <div class="logtivity-notice logtivity-notice-danger"> | |
| 58 | + <h2>Logtivity is misconfigured and logging has stopped.</h2> | |
| 59 | + <div> | |
| 60 | + Your App URL (<?php echo esc_html(logtivity_get_app_url()); ?>) | |
| 61 | + and API URL (<?php echo esc_html(logtivity_get_api_url()); ?>) | |
| 62 | + point to different environments. Neither | |
| 63 | + <code>LOGTIVITY_APP_URL</code> or <code>LOGTIVITY_API_URL</code> | |
| 64 | + constant should be set, or both must be set to the same | |
| 65 | + non-production environment. No logs will be sent until this is | |
| 66 | + corrected. | |
| 67 | + </div> | |
| 68 | + </div> | |
| 69 | + <?php elseif (logtivity_is_production() == false) : ?> | |
| 70 | + <div class="logtivity-notice logtivity-notice-warning"> | |
| 71 | + <h2>This site is not sending logs to the production application.</h2> | |
| 72 | + <div> | |
| 73 | + See your dashboard at | |
| 74 | + <a target="_blank" | |
| 75 | + rel="noopener noreferrer" | |
| 76 | + href="<?php echo esc_url(logtivity_get_app_url()); ?>"> | |
| 77 | + <?php esc_html_e('Logtivity dashboard', 'logtivity'); ?> | |
| 78 | + </a> | |
| 79 | + </div> | |
| 80 | + </div> | |
| 81 | + <?php endif; ?> | |
| 72 | 82 | |
| 73 | - <input <?php echo ( has_filter('logtivity_should_log_profile_link') ? 'readonly' : ''); ?> type="checkbox" name="logtivity_should_log_profile_link" id="logtivity_should_log_profile_link" value="1" class="regular-checkbox" <?php echo ( absint($options['logtivity_should_log_profile_link']) ? 'checked' : ''); ?>> | |
| 74 | - </td> | |
| 75 | - <td> | |
| 76 | - <span class="description">If you check this box, when logging an action, we will include the users profile link in the logged action.</span> | |
| 77 | - </td> | |
| 78 | - </tr> | |
| 79 | - <tr class="user-user-login-wrap"> | |
| 80 | - <th> | |
| 81 | - <label for="logtivity_should_log_username">Store Users Username</label> | |
| 82 | - <?php if (has_filter('logtivity_should_log_username')): ?> | |
| 83 | - <div class="logtivity-constant">This option has been set in code.</div> | |
| 84 | - <?php endif ?> | |
| 85 | - </th> | |
| 86 | - <td> | |
| 87 | - <input type="hidden" name="logtivity_should_log_username" id="logtivity_should_log_username" value="0"> | |
| 83 | + <form action="<?php echo esc_url(admin_url('admin-ajax.php?action=logtivity_update_settings')); ?>" method="post"> | |
| 88 | 84 | |
| 89 | - <input <?php echo ( has_filter('logtivity_should_log_username') ? 'readonly' : ''); ?> type="checkbox" name="logtivity_should_log_username" id="logtivity_should_log_username" value="1" class="regular-checkbox" <?php echo ( absint($options['logtivity_should_log_username']) ? 'checked' : ''); ?>> | |
| 90 | - </td> | |
| 91 | - <td> | |
| 92 | - <span class="description">If you check this box, when logging an action, we will include the users username in the logged action.</span> | |
| 93 | - </td> | |
| 94 | - </tr> | |
| 95 | - <tr class="user-user-login-wrap"> | |
| 96 | - <th> | |
| 97 | - <label for="logtivity_should_store_ip">Store Users IP Address</label> | |
| 98 | - <?php if (has_filter('logtivity_should_store_ip')): ?> | |
| 99 | - <div class="logtivity-constant">This option has been set in code.</div> | |
| 100 | - <?php endif ?> | |
| 101 | - </th> | |
| 102 | - <td> | |
| 103 | - <input type="hidden" name="logtivity_should_store_ip" id="logtivity_should_store_ip" value="0"> | |
| 85 | + <?php wp_nonce_field('logtivity_update_settings', 'logtivity_update_settings') ?> | |
| 104 | 86 | |
| 105 | - <input <?php echo ( has_filter('logtivity_should_store_ip') ? 'readonly' : ''); ?> type="checkbox" name="logtivity_should_store_ip" id="logtivity_should_store_ip" value="1" class="regular-checkbox" <?php echo ( absint($options['logtivity_should_store_ip']) ? 'checked' : ''); ?>> | |
| 106 | - </td> | |
| 107 | - <td> | |
| 108 | - <span class="description">If you check this box, when logging an action, we will include the users IP address in the logged action.</span> | |
| 109 | - </td> | |
| 110 | - </tr> | |
| 111 | - <tr class="user-user-login-wrap"> | |
| 112 | - <th> | |
| 113 | - <label for="logtivity_enable_debug_mode">Enable debug mode (recommended off by default)</label> | |
| 114 | - <?php if (has_filter('logtivity_enable_debug_mode')): ?> | |
| 115 | - <div class="logtivity-constant">This option has been set in code.</div> | |
| 116 | - <?php endif ?> | |
| 117 | - </th> | |
| 118 | - <td> | |
| 119 | - <input type="hidden" name="logtivity_enable_debug_mode" id="logtivity_enable_debug_mode" value="0"> | |
| 87 | + <table class="form-table"> | |
| 88 | + <tbody> | |
| 89 | + <tr class="user-user-login-wrap"> | |
| 90 | + <th scope="row"> | |
| 91 | + <label for="logtivity_site_api_key">Site API Key</label> | |
| 92 | + <?php if (has_filter('logtivity_site_api_key')): ?> | |
| 93 | + <div class="logtivity-constant">This option has been set in code.</div> | |
| 94 | + <?php endif ?> | |
| 95 | + </th> | |
| 120 | 96 | |
| 121 | - <input <?php echo ( has_filter('logtivity_enable_debug_mode') ? 'readonly' : ''); ?> type="checkbox" name="logtivity_enable_debug_mode" id="logtivity_enable_debug_mode" value="1" class="regular-checkbox" <?php echo ( absint($options['logtivity_enable_debug_mode']) ? 'checked' : ''); ?>> | |
| 122 | - </td> | |
| 123 | - <td> | |
| 124 | - <span class="description">This will log the latest response from the Logtivity API. This can be useful for debugging the result from an API call when storing a log. We <strong>recommend setting this to off by default</strong> as this will allow us to send logs asynchronously and not wait for a response from the API. This will be more performant.</span> | |
| 125 | - </td> | |
| 126 | - </tr> | |
| 127 | - </tbody> | |
| 128 | - </table> | |
| 97 | + <td> | |
| 98 | + <input id="logtivity_site_api_key" | |
| 99 | + name="logtivity_site_api_key" | |
| 100 | + type="text" | |
| 101 | + <?php echo has_filter('logtivity_site_api_key') ? 'readonly' : ''; ?> | |
| 102 | + value="<?php echo esc_attr($apiKey); ?>" | |
| 103 | + class="regular-text"> | |
| 104 | + <p> | |
| 105 | + Status: | |
| 106 | + <?php | |
| 107 | + switch ($connectionStatus) { | |
| 108 | + case 'success': | |
| 109 | + echo '<span style="color: #4caf50; font-weight: bold;">Connected</span>'; | |
| 110 | + break; | |
| 129 | 111 | |
| 130 | - <p class="submit"> | |
| 131 | - <input type="submit" name="submit" id="submit" class="button button-primary" value="Update Settings"> | |
| 132 | - </p> | |
| 112 | + case 'paused': | |
| 113 | + echo '<span style="color: #dbbf24; font-weight: bold;">Logging is paused</span>'; | |
| 114 | + echo '<br>' . esc_html($api->getConnectionMessage()); | |
| 115 | + break; | |
| 133 | 116 | |
| 134 | - </form> | |
| 117 | + case 'staging': | |
| 118 | + echo '<span style="color: #dbbf24; font-weight: bold;">' . esc_html($api->getConnectionMessage()) . '</span>'; | |
| 119 | + break; | |
| 135 | 120 | |
| 136 | - </div> | |
| 137 | -</div> | |
| 121 | + case 'fail': | |
| 122 | + echo '<span style="color: #ff3232; font-weight: bold;">' . esc_html($api->getConnectionMessage()) . '</span>'; | |
| 123 | + break; | |
| 138 | 124 | |
| 139 | -<?php if (absint( $options['logtivity_enable_debug_mode'] )): ?> | |
| 125 | + default: | |
| 126 | + if ($apiKey) { | |
| 127 | + echo '<span style="color: #ffdd32; font-weight: bold;">Unknown error</span>'; | |
| 128 | + } else { | |
| 129 | + echo '<span style="font-weight: bold;">Enter this site\'s API Key</span>'; | |
| 130 | + } | |
| 131 | + break; | |
| 132 | + } | |
| 133 | + ?> | |
| 134 | + </p> | |
| 135 | + </td> | |
| 140 | 136 | |
| 141 | - <div class="postbox"> | |
| 142 | - <div class="inside"> | |
| 137 | + <td style="vertical-align: top;"> | |
| 138 | + <span class="description"> | |
| 139 | + You can find this value by logging into your account | |
| 140 | + and navigating to this site's settings page. | |
| 141 | + </span> | |
| 142 | + </td> | |
| 143 | + </tr> | |
| 143 | 144 | |
| 144 | - <h3>Latest Response</h3> | |
| 145 | + <tr class="user-user-login-wrap"> | |
| 146 | + <th scope="row"> | |
| 147 | + <label for="logtivity_should_store_user_id">Store User ID</label> | |
| 148 | + <?php if (has_filter('logtivity_should_store_user_id')): ?> | |
| 149 | + <div class="logtivity-constant">This option has been set in code.</div> | |
| 150 | + <?php endif ?> | |
| 151 | + </th> | |
| 145 | 152 | |
| 146 | - <?php if ($latest_response = $options['logtivity_latest_response']): ?> | |
| 153 | + <td> | |
| 154 | + <input name="logtivity_should_store_user_id" | |
| 155 | + type="hidden" | |
| 156 | + value="0"> | |
| 147 | 157 | |
| 148 | - <h4>Date: <?php echo sanitize_text_field($latest_response['date']); ?></h4> | |
| 158 | + <input id="logtivity_should_store_user_id" | |
| 159 | + name="logtivity_should_store_user_id" | |
| 160 | + type="checkbox" | |
| 161 | + <?php echo $options['logtivity_should_store_user_id'] ? 'checked' : ''; ?> | |
| 162 | + <?php echo has_filter('logtivity_should_store_user_id') ? 'readonly' : ''; ?> | |
| 163 | + value="1" | |
| 164 | + class="regular-checkbox"> | |
| 165 | + </td> | |
| 149 | 166 | |
| 150 | - <?php if ($latest_response['response']): ?> | |
| 151 | - <code style="display: block; padding: 20px;"> | |
| 152 | - | |
| 153 | - <?php echo sanitize_text_field($latest_response['response']); ?> | |
| 167 | + <td> | |
| 168 | + <span class="description"> | |
| 169 | + If you check this box, when logging an action, | |
| 170 | + we will include the users User ID in the logged action. | |
| 171 | + </span> | |
| 172 | + </td> | |
| 173 | + </tr> | |
| 154 | 174 | |
| 155 | - </code> | |
| 156 | - <?php endif ?> | |
| 157 | - | |
| 158 | - <?php else: ?> | |
| 175 | + <tr class="user-user-login-wrap"> | |
| 176 | + <th scope="row"> | |
| 177 | + <label for="logtivity_should_log_profile_link">Store Users Profile Link</label> | |
| 178 | + <?php if (has_filter('logtivity_should_log_profile_link')): ?> | |
| 179 | + <div class="logtivity-constant">This option has been set in code.</div> | |
| 180 | + <?php endif ?> | |
| 181 | + </th> | |
| 159 | 182 | |
| 160 | - <p>The latest logging response will appear here after an event has been logged.</p> | |
| 183 | + <td> | |
| 184 | + <input name="logtivity_should_log_profile_link" | |
| 185 | + type="hidden" | |
| 186 | + value="0"> | |
| 161 | 187 | |
| 162 | - <?php endif ?> | |
| 163 | - | |
| 164 | - </div> | |
| 165 | - </div> | |
| 188 | + <input id="logtivity_should_log_profile_link" | |
| 189 | + name="logtivity_should_log_profile_link" | |
| 190 | + type="checkbox" | |
| 191 | + <?php echo $options['logtivity_should_log_profile_link'] ? 'checked' : ''; ?> | |
| 192 | + <?php echo has_filter('logtivity_should_log_profile_link') ? 'readonly' : ''; ?> | |
| 193 | + value="1" | |
| 194 | + class="regular-checkbox"> | |
| 195 | + </td> | |
| 166 | 196 | |
| 197 | + <td> | |
| 198 | + <span class="description"> | |
| 199 | + If you check this box, when logging an action, | |
| 200 | + we will include the users profile link in the logged action. | |
| 201 | + </span> | |
| 202 | + </td> | |
| 203 | + </tr> | |
| 204 | + | |
| 205 | + <tr class="user-user-login-wrap"> | |
| 206 | + <th scope="row"> | |
| 207 | + <label for="logtivity_should_log_username">Store Users Username</label> | |
| 208 | + <?php if (has_filter('logtivity_should_log_username')): ?> | |
| 209 | + <div class="logtivity-constant">This option has been set in code.</div> | |
| 210 | + <?php endif ?> | |
| 211 | + </th> | |
| 212 | + | |
| 213 | + <td> | |
| 214 | + <input name="logtivity_should_log_username" | |
| 215 | + type="hidden" | |
| 216 | + value="0"> | |
| 217 | + | |
| 218 | + <input id="logtivity_should_log_username" | |
| 219 | + name="logtivity_should_log_username" | |
| 220 | + type="checkbox" | |
| 221 | + <?php echo has_filter('logtivity_should_log_username') ? 'readonly' : ''; ?> | |
| 222 | + <?php echo $options['logtivity_should_log_username'] ? 'checked' : ''; ?> | |
| 223 | + value="1" | |
| 224 | + class="regular-checkbox"> | |
| 225 | + </td> | |
| 226 | + | |
| 227 | + <td> | |
| 228 | + <span class="description"> | |
| 229 | + If you check this box, when logging an action, | |
| 230 | + we will include the users username in the logged action. | |
| 231 | + </span> | |
| 232 | + </td> | |
| 233 | + </tr> | |
| 234 | + | |
| 235 | + <tr class="user-user-login-wrap"> | |
| 236 | + <th scope="row"> | |
| 237 | + <label for="logtivity_should_store_ip">Store Users IP Address</label> | |
| 238 | + <?php if (has_filter('logtivity_should_store_ip')): ?> | |
| 239 | + <div class="logtivity-constant">This option has been set in code.</div> | |
| 240 | + <?php endif ?> | |
| 241 | + </th> | |
| 242 | + | |
| 243 | + <td> | |
| 244 | + <input name="logtivity_should_store_ip" | |
| 245 | + type="hidden" | |
| 246 | + value="0"> | |
| 247 | + | |
| 248 | + <input id="logtivity_should_store_ip" | |
| 249 | + name="logtivity_should_store_ip" | |
| 250 | + type="checkbox" | |
| 251 | + <?php echo $options['logtivity_should_store_ip'] ? 'checked' : ''; ?> | |
| 252 | + <?php echo has_filter('logtivity_should_store_ip') ? 'readonly' : ''; ?> | |
| 253 | + value="1" | |
| 254 | + class="regular-checkbox"> | |
| 255 | + </td> | |
| 256 | + | |
| 257 | + <td> | |
| 258 | + <span class="description"> | |
| 259 | + If you check this box, when logging an action, | |
| 260 | + we will include the users IP address in the logged action. | |
| 261 | + </span> | |
| 262 | + </td> | |
| 263 | + </tr> | |
| 264 | + | |
| 265 | + <tr class="user-user-login-wrap"> | |
| 266 | + <th scope="row"> | |
| 267 | + <label for="logtivity_app_verify_url"> | |
| 268 | + Verify Site URL | |
| 269 | + </label> | |
| 270 | + <?php if (has_filter('logtivity_app_verify_url')): ?> | |
| 271 | + <div class="logtivity-constant">This option has been set in code.</div> | |
| 272 | + <?php endif ?> | |
| 273 | + </th> | |
| 274 | + | |
| 275 | + <td> | |
| 276 | + <input name="logtivity_app_verify_url" | |
| 277 | + type="hidden" | |
| 278 | + value="0"> | |
| 279 | + | |
| 280 | + <input id="logtivity_app_verify_url" | |
| 281 | + name="logtivity_app_verify_url" | |
| 282 | + type="checkbox" | |
| 283 | + <?php echo $options['logtivity_app_verify_url'] ? 'checked' : ''; ?> | |
| 284 | + <?php echo has_filter('logtivity_app_verify_url') ? 'readonly' : ''; ?> | |
| 285 | + value="1" | |
| 286 | + class="regular-checkbox"> | |
| 287 | + </td> | |
| 288 | + | |
| 289 | + <td> | |
| 290 | + <span class="description"> | |
| 291 | + When messages are sent to Logtivity, the site URL will be checked | |
| 292 | + against the URL Logtivity has on file for this API Key. If they do | |
| 293 | + not match, logging will be paused. | |
| 294 | + </span> | |
| 295 | + </td> | |
| 296 | + </tr> | |
| 297 | + | |
| 298 | + <tr class="user-user-login-wrap"> | |
| 299 | + <th scope="row"> | |
| 300 | + <label for="logtivity_enable_debug_mode"> | |
| 301 | + Enable debug mode (recommended off by default) | |
| 302 | + </label> | |
| 303 | + <?php if (has_filter('logtivity_enable_debug_mode')): ?> | |
| 304 | + <div class="logtivity-constant">This option has been set in code.</div> | |
| 305 | + <?php endif ?> | |
| 306 | + </th> | |
| 307 | + | |
| 308 | + <td> | |
| 309 | + <input name="logtivity_enable_debug_mode" | |
| 310 | + type="hidden" | |
| 311 | + value="0"> | |
| 312 | + | |
| 313 | + <input id="logtivity_enable_debug_mode" | |
| 314 | + name="logtivity_enable_debug_mode" | |
| 315 | + type="checkbox" | |
| 316 | + <?php echo $options['logtivity_enable_debug_mode'] ? 'checked' : ''; ?> | |
| 317 | + <?php echo has_filter('logtivity_enable_debug_mode') ? 'readonly' : ''; ?> | |
| 318 | + value="1" | |
| 319 | + class="regular-checkbox"> | |
| 320 | + </td> | |
| 321 | + | |
| 322 | + <td> | |
| 323 | + <span class="description"> | |
| 324 | + This will record a history of request and response data for API calls | |
| 325 | + to a debug log file (<code>wp-content/uploads/logtivity-logs/debug.log</code>), | |
| 326 | + viewable below. Response details are only captured for calls that already | |
| 327 | + wait for a response (periodic settings check-ins, roughly every 10 minutes); | |
| 328 | + other calls are still sent without waiting and only the outgoing request is | |
| 329 | + logged. Enabling this does not affect performance. | |
| 330 | + </span> | |
| 331 | + </td> | |
| 332 | + </tr> | |
| 333 | + | |
| 334 | + <tr class="user-user-login-wrap"> | |
| 335 | + <th scope="row"> | |
| 336 | + <label for="logtivity_disable_individual_logs">Disable Individual Logs</label> | |
| 337 | + <?php if (has_filter('logtivity_disable_individual_logs')): ?> | |
| 338 | + <div class="logtivity-constant">This option has been set in code.</div> | |
| 339 | + <?php endif ?> | |
| 340 | + </th> | |
| 341 | + <td> | |
| 342 | + <textarea id="logtivity_disable_individual_logs" | |
| 343 | + name="logtivity_disable_individual_logs" | |
| 344 | + class="regular-checkbox" | |
| 345 | + style="width: 100%;" | |
| 346 | + <?php echo has_filter('logtivity_disable_individual_logs') ? 'readonly' : ''; ?> | |
| 347 | + rows="10" | |
| 348 | + placeholder="User Logged In User Created && subscriber" | |
| 349 | + ><?php echo esc_html($options['logtivity_disable_individual_logs']); ?></textarea> | |
| 350 | + </td> | |
| 351 | + | |
| 352 | + <td> | |
| 353 | + <span class="description"> | |
| 354 | + You can disable individual logged actions here by listing the action names, one per line. | |
| 355 | + <br> | |
| 356 | + <br> | |
| 357 | + To specify the context field as well, | |
| 358 | + separate the action and context keywords with an && symbol. | |
| 359 | + <br> | |
| 360 | + <br> | |
| 361 | + <?php | |
| 362 | + if ( | |
| 363 | + isset($options['logtivity_enable_white_label_mode']) == false | |
| 364 | + || $options['logtivity_enable_white_label_mode'] != 1 | |
| 365 | + ): | |
| 366 | + ?> | |
| 367 | + If you have multiple sites on Logtivity and would rather control disabled | |
| 368 | + logs globally you can go to the | |
| 369 | + <?php | |
| 370 | + printf( | |
| 371 | + '<a href="%s" target="_blank" rel="nofollow">%s</a>', | |
| 372 | + esc_url(logtivity_get_app_url() . '/team-settings/activity-log-settings'), | |
| 373 | + esc_html__('Activity Log Settings page', 'logtivity') | |
| 374 | + ); | |
| 375 | + ?> | |
| 376 | + in your Logtivity dashboard. | |
| 377 | + <?php endif; ?> | |
| 378 | + </span> | |
| 379 | + </td> | |
| 380 | + </tr> | |
| 381 | + </tbody> | |
| 382 | + </table> | |
| 383 | + | |
| 384 | + <p class="submit"> | |
| 385 | + <input id="submit" | |
| 386 | + name="submit" | |
| 387 | + type="submit" | |
| 388 | + class="button button-primary" | |
| 389 | + value="Update Settings"> | |
| 390 | + </p> | |
| 391 | + </form> | |
| 392 | + | |
| 393 | + </div> | |
| 394 | +</div> | |
| 395 | + | |
| 396 | +<?php if ($options['logtivity_enable_debug_mode']): ?> | |
| 397 | + | |
| 398 | + <div class="postbox"> | |
| 399 | + <div class="inside"> | |
| 400 | + | |
| 401 | + <h3>Debug Log</h3> | |
| 402 | + | |
| 403 | + <form method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>" style="display: inline-block; margin-bottom: 15px;"> | |
| 404 | + <input type="hidden" name="action" value="logtivity_clear_debug_log"> | |
| 405 | + <?php wp_nonce_field('logtivity_clear_debug_log', 'logtivity_clear_debug_log'); ?> | |
| 406 | + <input id="logtivity-clear-debug-log" | |
| 407 | + type="submit" | |
| 408 | + class="button" | |
| 409 | + value="Clear Debug Log" | |
| 410 | + onclick="return confirm('Are you sure you want to clear the debug log?');"> | |
| 411 | + </form> | |
| 412 | + | |
| 413 | + <?php if ($debugLogEntries) : ?> | |
| 414 | + <a id="logtivity-download-debug-log" | |
| 415 | + class="button" | |
| 416 | + style="margin-bottom: 15px;" | |
| 417 | + href="<?php | |
| 418 | + echo esc_url(wp_nonce_url( | |
| 419 | + admin_url('admin-post.php?action=logtivity_download_debug_log'), | |
| 420 | + 'logtivity_download_debug_log', | |
| 421 | + 'logtivity_download_debug_log' | |
| 422 | + )); | |
| 423 | + ?>"> | |
| 424 | + Download Debug Log | |
| 425 | + </a> | |
| 426 | + <?php endif; ?> | |
| 427 | + | |
| 428 | + <?php if ($debugLogEntries) : ?> | |
| 429 | + <?php foreach ($debugLogEntries as $entry) : ?> | |
| 430 | + <div style="border-bottom: 1px solid #ddd; padding: 10px 0;"> | |
| 431 | + <h4> | |
| 432 | + <?php echo esc_html($entry['timestamp'] ?? ''); ?> | |
| 433 | + — | |
| 434 | + <?php echo esc_html($entry['method'] ?? ''); ?> | |
| 435 | + <?php echo esc_html($entry['endpoint'] ?? ''); ?> | |
| 436 | + </h4> | |
| 437 | + <?php $responseCode = $entry['response_code'] ?? null; ?> | |
| 438 | + <h4> | |
| 439 | + Response: | |
| 440 | + <?php | |
| 441 | + echo $responseCode === null | |
| 442 | + ? 'not captured (sent without waiting for a response)' | |
| 443 | + : esc_html(sprintf( | |
| 444 | + '%s - %s (%sms)', | |
| 445 | + $responseCode, | |
| 446 | + $entry['response_message'] ?? 'No Message', | |
| 447 | + $entry['response_time_ms'] ?? 'NA' | |
| 448 | + )); | |
| 449 | + ?> | |
| 450 | + </h4> | |
| 451 | + <code style="display: block; padding: 20px; overflow-x: auto;"> | |
| 452 | + Request: <?php echo esc_html(wp_json_encode($entry['request_body'] ?? null)); ?> | |
| 453 | + </code> | |
| 454 | + <?php if ($responseCode !== null) : ?> | |
| 455 | + <code style="display: block; padding: 20px; overflow-x: auto;"> | |
| 456 | + Response: <?php echo esc_html(wp_json_encode($entry['response_body'] ?? null)); ?> | |
| 457 | + </code> | |
| 458 | + <?php endif; ?> | |
| 459 | + </div> | |
| 460 | + <?php endforeach; ?> | |
| 461 | + <?php else : ?> | |
| 462 | + <p>The debug log will appear here after an API call has been made.</p> | |
| 463 | + <?php endif; ?> | |
| 464 | + </div> | |
| 465 | + </div> | |
| 466 | + | |
| 167 | 467 | <?php endif ?> |
| 168 | 468 | |
| 169 | -<?php echo logtivity_view('_admin-footer', compact('options')); ?> | |
| 469 | +<?php | |
| 470 | +// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- logtivity_view() renders trusted plugin templates. | |
| 471 | +echo logtivity_view('_admin-footer', compact('options')); | |
| 472 | +?> | |