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