debug
9 years ago
forms
9 years ago
plugin-info
9 years ago
account.php
9 years ago
add-ons.php
9 years ago
add-trial-to-pricing.php
9 years ago
admin-notice.php
9 years ago
ajax-loader.php
9 years ago
all-admin-notice.php
9 years ago
auto-installation.php
9 years ago
billing.php
9 years ago
checkout-legacy.php
9 years ago
checkout.php
9 years ago
connect.php
9 years ago
contact.php
9 years ago
debug.php
9 years ago
email.php
9 years ago
firewall-issues-js.php
9 years ago
index.php
9 years ago
plugin-icon.php
9 years ago
powered-by.php
9 years ago
pricing.php
9 years ago
sticky-admin-notice-js.php
9 years ago
debug.php
587 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package Freemius |
| 4 | * @copyright Copyright (c) 2015, Freemius, Inc. |
| 5 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 6 | * @since 1.1.1 |
| 7 | */ |
| 8 | |
| 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 10 | exit; |
| 11 | } |
| 12 | |
| 13 | global $fs_active_plugins; |
| 14 | |
| 15 | $fs_options = FS_Option_Manager::get_manager( WP_FS__ACCOUNTS_OPTION_NAME, true ); |
| 16 | ?> |
| 17 | <h1><?php echo fs_text( 'Freemius Debug' ) . ' - ' . fs_text( 'SDK' ) . ' v.' . $fs_active_plugins->newest->version ?></h1> |
| 18 | <div> |
| 19 | <!-- Debugging Switch --> |
| 20 | <?php //$debug_mode = get_option( 'fs_debug_mode', null ) ?> |
| 21 | <span class="switch-label"><?php fs_echo( 'debugging' ) ?></span> |
| 22 | |
| 23 | <div class="switch <?php echo WP_FS__DEBUG_SDK ? 'off' : 'on' ?>"> |
| 24 | <div class="toggle"></div> |
| 25 | <span class="on"><?php fs_echo( 'on' ) ?></span> |
| 26 | <span class="off"><?php fs_echo( 'off' ) ?></span> |
| 27 | </div> |
| 28 | <script type="text/javascript"> |
| 29 | (function ($) { |
| 30 | $(document).ready(function () { |
| 31 | // Switch toggle |
| 32 | $('.switch').click(function () { |
| 33 | $(this) |
| 34 | .toggleClass('on') |
| 35 | .toggleClass('off'); |
| 36 | |
| 37 | $.post(ajaxurl, { |
| 38 | action: 'fs_toggle_debug_mode', |
| 39 | is_on : ($(this).hasClass('off') ? 1 : 0) |
| 40 | }, function (response) { |
| 41 | if (1 == response) { |
| 42 | // Refresh page on success. |
| 43 | location.reload(); |
| 44 | } |
| 45 | }); |
| 46 | }); |
| 47 | }); |
| 48 | }(jQuery)); |
| 49 | </script> |
| 50 | </div> |
| 51 | <h2><?php fs_echo( 'actions' ) ?></h2> |
| 52 | <table> |
| 53 | <tbody> |
| 54 | <tr> |
| 55 | <td> |
| 56 | <!-- Delete All Accounts --> |
| 57 | <form action="" method="POST"> |
| 58 | <input type="hidden" name="fs_action" value="restart_freemius"> |
| 59 | <?php wp_nonce_field( 'restart_freemius' ) ?> |
| 60 | <button class="button button-primary" |
| 61 | onclick="if (confirm('<?php fs_echo( 'delete-all-confirm' ) ?>')) this.parentNode.submit(); return false;"><?php fs_echo( 'delete-all-accounts' ) ?></button> |
| 62 | </form> |
| 63 | </td> |
| 64 | <td> |
| 65 | <!-- Clear API Cache --> |
| 66 | <form action="" method="POST"> |
| 67 | <input type="hidden" name="fs_clear_api_cache" value="true"> |
| 68 | <button class="button button-primary"><?php fs_echo( 'clear-api-cache' ) ?></button> |
| 69 | </form> |
| 70 | </td> |
| 71 | <td> |
| 72 | <!-- Sync Data with Server --> |
| 73 | <form action="" method="POST"> |
| 74 | <input type="hidden" name="background_sync" value="true"> |
| 75 | <button class="button button-primary"><?php fs_echo( 'sync-data-from-server' ) ?></button> |
| 76 | </form> |
| 77 | </td> |
| 78 | <td> |
| 79 | <button id="fs_load_db_option" class="button"><?php fs_echo( 'Load DB Option' ) ?></button> |
| 80 | </td> |
| 81 | <td> |
| 82 | <button id="fs_set_db_option" class="button"><?php fs_echo( 'Set DB Option' ) ?></button> |
| 83 | </td> |
| 84 | </tr> |
| 85 | </tbody> |
| 86 | </table> |
| 87 | <script type="text/javascript"> |
| 88 | (function($){ |
| 89 | $('#fs_load_db_option').click(function () { |
| 90 | var optionName = prompt('Please enter the option name:'); |
| 91 | |
| 92 | if (optionName) { |
| 93 | $.post(ajaxurl, { |
| 94 | action : 'fs_get_db_option', |
| 95 | option_name: optionName |
| 96 | }, function (response) { |
| 97 | if (response.data.value) |
| 98 | prompt('The option value is:', response.data.value); |
| 99 | else |
| 100 | alert('Oops... Option does not exist in the DB.'); |
| 101 | }); |
| 102 | } |
| 103 | }); |
| 104 | |
| 105 | $('#fs_set_db_option').click(function () { |
| 106 | var optionName = prompt('Please enter the option name:'); |
| 107 | |
| 108 | if (optionName) { |
| 109 | var optionValue = prompt('Please enter the option value:'); |
| 110 | |
| 111 | if (optionValue) { |
| 112 | $.post(ajaxurl, { |
| 113 | action : 'fs_set_db_option', |
| 114 | option_name : optionName, |
| 115 | option_value: optionValue |
| 116 | }, function () { |
| 117 | alert('Option was successfully set.'); |
| 118 | }); |
| 119 | } |
| 120 | } |
| 121 | }); |
| 122 | })(jQuery); |
| 123 | </script> |
| 124 | <?php |
| 125 | if ( ! defined( 'FS_API__ADDRESS' ) ) { |
| 126 | define( 'FS_API__ADDRESS', '://api.freemius.com' ); |
| 127 | } |
| 128 | if ( ! defined( 'FS_API__SANDBOX_ADDRESS' ) ) { |
| 129 | define( 'FS_API__SANDBOX_ADDRESS', '://sandbox-api.freemius.com' ); |
| 130 | } |
| 131 | |
| 132 | $defines = array( |
| 133 | array( |
| 134 | 'key' => 'WP_FS__REMOTE_ADDR', |
| 135 | 'val' => WP_FS__REMOTE_ADDR, |
| 136 | ), |
| 137 | array( |
| 138 | 'key' => 'WP_FS__ADDRESS_PRODUCTION', |
| 139 | 'val' => WP_FS__ADDRESS_PRODUCTION, |
| 140 | ), |
| 141 | array( |
| 142 | 'key' => 'FS_API__ADDRESS', |
| 143 | 'val' => FS_API__ADDRESS, |
| 144 | ), |
| 145 | array( |
| 146 | 'key' => 'FS_API__SANDBOX_ADDRESS', |
| 147 | 'val' => FS_API__SANDBOX_ADDRESS, |
| 148 | ), |
| 149 | array( |
| 150 | 'key' => 'WP_FS__DIR', |
| 151 | 'val' => WP_FS__DIR, |
| 152 | ), |
| 153 | ) |
| 154 | ?> |
| 155 | <br> |
| 156 | <table class="widefat"> |
| 157 | <thead> |
| 158 | <tr> |
| 159 | <th><?php fs_echo( 'key' ) ?></th> |
| 160 | <th><?php fs_echo( 'value' ) ?></th> |
| 161 | </tr> |
| 162 | </thead> |
| 163 | <tbody> |
| 164 | <?php $alternate = false; |
| 165 | foreach ( $defines as $p ) : ?> |
| 166 | <tr<?php if ( $alternate ) { |
| 167 | echo ' class="alternate"'; |
| 168 | } ?>> |
| 169 | <td><?php echo $p['key'] ?></td> |
| 170 | <td><?php echo $p['val'] ?></td> |
| 171 | </tr> |
| 172 | <?php $alternate = ! $alternate ?> |
| 173 | <?php endforeach ?> |
| 174 | </tbody> |
| 175 | </table> |
| 176 | <h2><?php fs_echo( 'sdk-versions' ) ?></h2> |
| 177 | <table id="fs_sdks" class="widefat"> |
| 178 | <thead> |
| 179 | <tr> |
| 180 | <th><?php fs_echo( 'version' ) ?></th> |
| 181 | <th><?php fs_echo( 'sdk-path' ) ?></th> |
| 182 | <th><?php fs_echo( 'plugin-path' ) ?></th> |
| 183 | <th><?php fs_echo( 'is-active' ) ?></th> |
| 184 | </tr> |
| 185 | </thead> |
| 186 | <tbody> |
| 187 | <?php foreach ( $fs_active_plugins->plugins as $sdk_path => &$data ) : ?> |
| 188 | <?php $is_active = ( WP_FS__SDK_VERSION == $data->version ) ?> |
| 189 | <tr<?php if ( $is_active ) { |
| 190 | echo ' style="background: #E6FFE6; font-weight: bold"'; |
| 191 | } ?>> |
| 192 | <td><?php echo $data->version ?></td> |
| 193 | <td><?php echo $sdk_path ?></td> |
| 194 | <td><?php echo $data->plugin_path ?></td> |
| 195 | <td><?php echo ( $is_active ) ? 'Active' : 'Inactive' ?></td> |
| 196 | </tr> |
| 197 | <?php endforeach ?> |
| 198 | </tbody> |
| 199 | </table> |
| 200 | <?php $plugins = $fs_options->get_option( 'plugins' ) ?> |
| 201 | <?php if ( is_array( $plugins ) && 0 < count( $plugins ) ) : ?> |
| 202 | <h2><?php fs_echo( 'plugins' ) ?></h2> |
| 203 | <table id="fs_plugins" class="widefat"> |
| 204 | <thead> |
| 205 | <tr> |
| 206 | <th><?php fs_echo( 'id' ) ?></th> |
| 207 | <th><?php fs_echo( 'slug' ) ?></th> |
| 208 | <th><?php fs_echo( 'version' ) ?></th> |
| 209 | <th><?php fs_echo( 'title' ) ?></th> |
| 210 | <th><?php fs_echo( 'api' ) ?></th> |
| 211 | <th><?php fs_echo( 'freemius-state' ) ?></th> |
| 212 | <th><?php fs_echo( 'plugin-path' ) ?></th> |
| 213 | <th><?php fs_echo( 'public-key' ) ?></th> |
| 214 | <th><?php fs_echo( 'actions' ) ?></th> |
| 215 | </tr> |
| 216 | </thead> |
| 217 | <tbody> |
| 218 | <?php foreach ( $plugins as $slug => $data ) : ?> |
| 219 | <?php $is_active = is_plugin_active( $data->file ) ?> |
| 220 | <?php $fs = $is_active ? freemius( $slug ) : null ?> |
| 221 | <tr<?php if ( $is_active ) { |
| 222 | if ( $fs->has_api_connectivity() && $fs->is_on() ) { |
| 223 | echo ' style="background: #E6FFE6; font-weight: bold"'; |
| 224 | } else { |
| 225 | echo ' style="background: #ffd0d0; font-weight: bold"'; |
| 226 | } |
| 227 | } ?>> |
| 228 | <td><?php echo $data->id ?></td> |
| 229 | <td><?php echo $slug ?></td> |
| 230 | <td><?php echo $data->version ?></td> |
| 231 | <td><?php echo $data->title ?></td> |
| 232 | <td<?php if ( $is_active && ! $fs->has_api_connectivity() ) { |
| 233 | echo ' style="color: red; text-transform: uppercase;"'; |
| 234 | } ?>><?php if ( $is_active ) { |
| 235 | echo $fs->has_api_connectivity() ? |
| 236 | fs_text( 'connected' ) : |
| 237 | fs_text( 'blocked' ); |
| 238 | } ?></td> |
| 239 | <td<?php if ( $is_active && ! $fs->is_on() ) { |
| 240 | echo ' style="color: red; text-transform: uppercase;"'; |
| 241 | } ?>><?php if ( $is_active ) { |
| 242 | echo $fs->is_on() ? |
| 243 | fs_text( 'on' ) : |
| 244 | fs_text( 'off' ); |
| 245 | } ?></td> |
| 246 | <td><?php echo $data->file ?></td> |
| 247 | <td><?php echo $data->public_key ?></td> |
| 248 | <td> |
| 249 | <?php if ( $is_active && $fs->has_trial_plan() ) : ?> |
| 250 | <form action="" method="POST"> |
| 251 | <input type="hidden" name="fs_action" value="simulate_trial"> |
| 252 | <input type="hidden" name="slug" value="<?php echo $slug ?>"> |
| 253 | <?php wp_nonce_field( 'simulate_trial' ) ?> |
| 254 | |
| 255 | <button type="submit" |
| 256 | class="button button-primary simulate-trial"><?php fs_echo( 'Simulate Trial' ) ?></button> |
| 257 | </form> |
| 258 | <?php endif ?> |
| 259 | </td> |
| 260 | </tr> |
| 261 | <?php endforeach ?> |
| 262 | </tbody> |
| 263 | </table> |
| 264 | <?php endif ?> |
| 265 | <?php |
| 266 | /** |
| 267 | * @var array $VARS |
| 268 | * @var FS_Site[] $sites |
| 269 | */ |
| 270 | $sites = $VARS['sites']; |
| 271 | ?> |
| 272 | <?php if ( is_array( $sites ) && 0 < count( $sites ) ) : ?> |
| 273 | <h2><?php fs_echo( 'plugin-installs' ) ?> / <?php fs_echo( 'sites' ) ?></h2> |
| 274 | <table id="fs_installs" class="widefat"> |
| 275 | <thead> |
| 276 | <tr> |
| 277 | <th><?php fs_echo( 'id' ) ?></th> |
| 278 | <th><?php fs_echo( 'slug' ) ?></th> |
| 279 | <th><?php fs_echo( 'plan' ) ?></th> |
| 280 | <th><?php fs_echo( 'public-key' ) ?></th> |
| 281 | <th><?php fs_echo( 'secret-key' ) ?></th> |
| 282 | </tr> |
| 283 | </thead> |
| 284 | <tbody> |
| 285 | <?php foreach ( $sites as $slug => $site ) : ?> |
| 286 | <tr> |
| 287 | <td><?php echo $site->id ?></td> |
| 288 | <td><?php echo $slug ?></td> |
| 289 | <td><?php |
| 290 | echo is_object( $site->plan ) ? |
| 291 | Freemius::_decrypt( $site->plan->name ) : |
| 292 | '' |
| 293 | ?></td> |
| 294 | <td><?php echo $site->public_key ?></td> |
| 295 | <td><?php echo $site->secret_key ?></td> |
| 296 | </tr> |
| 297 | <?php endforeach ?> |
| 298 | </tbody> |
| 299 | </table> |
| 300 | <?php endif ?> |
| 301 | <?php |
| 302 | $addons = $VARS['addons']; |
| 303 | ?> |
| 304 | <?php foreach ( $addons as $plugin_id => $plugin_addons ) : ?> |
| 305 | <h2><?php printf( fs_text( 'addons-of-x' ), $plugin_id ) ?></h2> |
| 306 | <table id="fs_addons" class="widefat"> |
| 307 | <thead> |
| 308 | <tr> |
| 309 | <th><?php fs_echo( 'id' ) ?></th> |
| 310 | <th><?php fs_echo( 'title' ) ?></th> |
| 311 | <th><?php fs_echo( 'slug' ) ?></th> |
| 312 | <th><?php fs_echo( 'version' ) ?></th> |
| 313 | <th><?php fs_echo( 'public-key' ) ?></th> |
| 314 | <th><?php fs_echo( 'secret-key' ) ?></th> |
| 315 | </tr> |
| 316 | </thead> |
| 317 | <tbody> |
| 318 | <?php |
| 319 | /** |
| 320 | * @var FS_Plugin[] $plugin_addons |
| 321 | */ |
| 322 | foreach ( $plugin_addons as $addon ) : ?> |
| 323 | <tr> |
| 324 | <td><?php echo $addon->id ?></td> |
| 325 | <td><?php echo $addon->title ?></td> |
| 326 | <td><?php echo $addon->slug ?></td> |
| 327 | <td><?php echo $addon->version ?></td> |
| 328 | <td><?php echo $addon->public_key ?></td> |
| 329 | <td><?php echo $addon->secret_key ?></td> |
| 330 | </tr> |
| 331 | <?php endforeach ?> |
| 332 | </tbody> |
| 333 | </table> |
| 334 | <?php endforeach ?> |
| 335 | <?php |
| 336 | /** |
| 337 | * @var FS_User[] $users |
| 338 | */ |
| 339 | $users = $VARS['users']; |
| 340 | ?> |
| 341 | <?php if ( is_array( $users ) && 0 < count( $users ) ) : ?> |
| 342 | <h2><?php fs_echo( 'users' ) ?></h2> |
| 343 | <table id="fs_users" class="widefat"> |
| 344 | <thead> |
| 345 | <tr> |
| 346 | <th><?php fs_echo( 'id' ) ?></th> |
| 347 | <th><?php fs_echo( 'name' ) ?></th> |
| 348 | <th><?php fs_echo( 'email' ) ?></th> |
| 349 | <th><?php fs_echo( 'verified' ) ?></th> |
| 350 | <th><?php fs_echo( 'public-key' ) ?></th> |
| 351 | <th><?php fs_echo( 'secret-key' ) ?></th> |
| 352 | </tr> |
| 353 | </thead> |
| 354 | <tbody> |
| 355 | <?php foreach ( $users as $user_id => $user ) : ?> |
| 356 | <tr> |
| 357 | <td><?php echo $user->id ?></td> |
| 358 | <td><?php echo $user->get_name() ?></td> |
| 359 | <td><a href="mailto:<?php echo esc_attr( $user->email ) ?>"><?php echo $user->email ?></a></td> |
| 360 | <td><?php echo json_encode( $user->is_verified ) ?></td> |
| 361 | <td><?php echo $user->public_key ?></td> |
| 362 | <td><?php echo $user->secret_key ?></td> |
| 363 | </tr> |
| 364 | <?php endforeach ?> |
| 365 | </tbody> |
| 366 | </table> |
| 367 | <?php endif ?> |
| 368 | |
| 369 | <?php |
| 370 | /** |
| 371 | * @var FS_Plugin_License[] $licenses |
| 372 | */ |
| 373 | $licenses = $VARS['licenses']; |
| 374 | ?> |
| 375 | <?php if ( is_array( $licenses ) && 0 < count( $licenses ) ) : ?> |
| 376 | <h2><?php fs_echo( 'licenses' ) ?></h2> |
| 377 | <table id="fs_users" class="widefat"> |
| 378 | <thead> |
| 379 | <tr> |
| 380 | <th><?php fs_echo( 'id' ) ?></th> |
| 381 | <th><?php fs_echo( 'plugin-id' ) ?></th> |
| 382 | <th><?php fs_echo( 'user-id' ) ?></th> |
| 383 | <th><?php fs_echo( 'plan-id' ) ?></th> |
| 384 | <th><?php fs_echo( 'quota' ) ?></th> |
| 385 | <th><?php fs_echo( 'activated' ) ?></th> |
| 386 | <th><?php fs_echo( 'blocking' ) ?></th> |
| 387 | <th><?php fs_echo( 'license-key' ) ?></th> |
| 388 | <th><?php fs_echo( 'expiration' ) ?></th> |
| 389 | </tr> |
| 390 | </thead> |
| 391 | <tbody> |
| 392 | <?php foreach ( $licenses as $slug => $module_licenses ) : ?> |
| 393 | <?php foreach ( $module_licenses as $id => $licenses ) : ?> |
| 394 | <?php if ( is_array( $licenses ) && 0 < count( $licenses ) ) : ?> |
| 395 | <?php foreach ( $licenses as $license ) : ?> |
| 396 | <tr> |
| 397 | <td><?php echo $license->id ?></td> |
| 398 | <td><?php echo $license->plugin_id ?></td> |
| 399 | <td><?php echo $license->user_id ?></td> |
| 400 | <td><?php echo $license->plan_id ?></td> |
| 401 | <td><?php echo $license->is_unlimited() ? 'Unlimited' : ( $license->is_single_site() ? 'Single Site' : $license->quota ) ?></td> |
| 402 | <td><?php echo $license->activated ?></td> |
| 403 | <td><?php echo $license->is_block_features ? 'Blocking' : 'Flexible' ?></td> |
| 404 | <td><?php echo htmlentities( $license->secret_key ) ?></td> |
| 405 | <td><?php echo $license->expiration ?></td> |
| 406 | </tr> |
| 407 | <?php endforeach ?> |
| 408 | <?php endif ?> |
| 409 | <?php endforeach ?> |
| 410 | <?php endforeach ?> |
| 411 | </tbody> |
| 412 | </table> |
| 413 | <?php endif ?> |
| 414 | |
| 415 | <?php if ( FS_Logger::is_storage_logging_on() ) : ?> |
| 416 | |
| 417 | <h2><?php fs_echo( 'debug-log' ) ?></h2> |
| 418 | |
| 419 | <div id="fs_debug_filters"> |
| 420 | <select name="type"> |
| 421 | <option value="" selected="selected"><?php fs_echo( 'all-types' ) ?></option> |
| 422 | <option value="warn_error">Warnings & Errors</option> |
| 423 | <option value="error">Errors</option> |
| 424 | <option value="warn">Warnings</option> |
| 425 | <option value="info">Info</option> |
| 426 | </select> |
| 427 | <select name="request_type"> |
| 428 | <option value="" selected="selected"><?php fs_echo( 'all-requests' ) ?></option> |
| 429 | <option value="call">Sync</option> |
| 430 | <option value="ajax">AJAX</option> |
| 431 | <option value="cron">WP Cron</option> |
| 432 | </select> |
| 433 | <input name="file" type="text" placeholder="<?php fs_echo( 'file' ) ?>"/> |
| 434 | <input name="function" type="text" placeholder="<?php fs_echo( 'function' ) ?>"/> |
| 435 | <input name="process_id" type="text" placeholder="<?php fs_echo( 'process-id' ) ?>"/> |
| 436 | <input name="logger" type="text" placeholder="<?php fs_echo( 'logger' ) ?>"/> |
| 437 | <input name="message" type="text" placeholder="<?php fs_echo( 'message' ) ?>"/> |
| 438 | <div style="margin: 10px 0"> |
| 439 | <button id="fs_filter" class="button" style="float: left"><i class="dashicons dashicons-filter"></i> <?php fs_echo( 'filter' ) ?> |
| 440 | </button> |
| 441 | |
| 442 | <form action="" method="POST" style="float: left; margin-left: 10px;"> |
| 443 | <input type="hidden" name="fs_action" value="download_logs"> |
| 444 | <?php wp_nonce_field( 'download_logs' ) ?> |
| 445 | <div class="fs-filters"></div> |
| 446 | <button id="fs_download" class="button" type="submit"><i |
| 447 | class="dashicons dashicons-download"></i> <?php fs_echo( 'download' ) ?></button> |
| 448 | </form> |
| 449 | <div style="clear: both"></div> |
| 450 | </div> |
| 451 | </div> |
| 452 | |
| 453 | <div id="fs_log_book" style="height: 300px; overflow: auto;"> |
| 454 | <table class="widefat"> |
| 455 | <thead> |
| 456 | <tr> |
| 457 | <th>#</th> |
| 458 | <th><?php fs_echo( 'type' ) ?></th> |
| 459 | <th><?php fs_echo( 'id' ) ?></th> |
| 460 | <th><?php fs_echo( 'function' ) ?></th> |
| 461 | <th><?php fs_echo( 'message' ) ?></th> |
| 462 | <th><?php fs_echo( 'file' ) ?></th> |
| 463 | <th><?php fs_echo( 'timestamp' ) ?></th> |
| 464 | </tr> |
| 465 | </thead> |
| 466 | <tbody> |
| 467 | <tr style="display: none"> |
| 468 | <td>{$log.log_order}.</td> |
| 469 | <td class="fs-col--type">{$log.type}</td> |
| 470 | <td class="fs-col--logger">{$log.logger}</td> |
| 471 | <td class="fs-col--function">{$log.function}</td> |
| 472 | <td class="fs-col--message"> |
| 473 | <a href="#" onclick="jQuery(this).parent().find('div').toggle(); return false;"> |
| 474 | <nobr>{$log.message_short}</nobr> |
| 475 | </a> |
| 476 | <div style="display: none;">{$log.message}</div> |
| 477 | </td> |
| 478 | <td class="fs-col--file">{$log.file}:{$log.line}</td> |
| 479 | <td class="fs-col--timestamp">{$log.created}</td> |
| 480 | </tr> |
| 481 | |
| 482 | </tbody> |
| 483 | </table> |
| 484 | </div> |
| 485 | <script type="text/javascript"> |
| 486 | jQuery(document).ready(function ($) { |
| 487 | var filtersChanged = false, |
| 488 | offset = 0, |
| 489 | limit = 200, |
| 490 | prevFiltersSignature = null; |
| 491 | |
| 492 | var getFilters = function () { |
| 493 | var filters = {}, |
| 494 | signature = ''; |
| 495 | |
| 496 | $('#fs_debug_filters').find('select, input').each(function (i, e) { |
| 497 | var $element = $(e); |
| 498 | |
| 499 | if ('hidden' === $element.attr('type')) |
| 500 | return; |
| 501 | |
| 502 | var val = $element.val(); |
| 503 | if ('' !== val.trim()) { |
| 504 | var name = $(e).attr('name'); |
| 505 | filters[name] = val; |
| 506 | signature += name + '=' + val + '~'; |
| 507 | } |
| 508 | }); |
| 509 | |
| 510 | if (signature != prevFiltersSignature) { |
| 511 | filtersChanged = true; |
| 512 | prevFiltersSignature = signature; |
| 513 | } else { |
| 514 | filtersChanged = false; |
| 515 | } |
| 516 | |
| 517 | return filters; |
| 518 | }; |
| 519 | |
| 520 | $('#fs_download').parent().submit(function () { |
| 521 | var filters = getFilters(), |
| 522 | hiddenFields = ''; |
| 523 | |
| 524 | for (var f in filters) { |
| 525 | if (filters.hasOwnProperty(f)) { |
| 526 | hiddenFields += '<input type="hidden" name="filters[' + f + ']" value="' + filters[f] + '" />'; |
| 527 | } |
| 528 | } |
| 529 | |
| 530 | $(this).find('.fs-filters').html(hiddenFields); |
| 531 | }); |
| 532 | |
| 533 | var loadLogs = function () { |
| 534 | var $tbody = $('#fs_log_book tbody'), |
| 535 | template = $tbody.find('tr:first-child').html(), |
| 536 | filters = getFilters(); |
| 537 | |
| 538 | if (!filtersChanged) { |
| 539 | offset += limit; |
| 540 | } else { |
| 541 | // Cleanup table for new filter (only keep template row). |
| 542 | $tbody.find('tr').each(function(i, e){ |
| 543 | if (0 == i) |
| 544 | return; |
| 545 | |
| 546 | $(e).remove(); |
| 547 | }); |
| 548 | |
| 549 | offset = 0; |
| 550 | } |
| 551 | |
| 552 | $.post(ajaxurl, { |
| 553 | action : 'fs_get_debug_log', |
| 554 | filters: filters, |
| 555 | offset: offset, |
| 556 | limit: limit |
| 557 | }, function (response) { |
| 558 | |
| 559 | for (var i = 0; i < response.data.length; i++) { |
| 560 | var templateCopy = template; |
| 561 | |
| 562 | response.data[i].message_short = (response.data[i].message.length > 32) ? |
| 563 | response.data[i].message.substr(0, 32) + '...' : |
| 564 | response.data[i].message; |
| 565 | |
| 566 | for (var p in response.data[i]) { |
| 567 | if (response.data[i].hasOwnProperty(p)) { |
| 568 | templateCopy = templateCopy.replace('{$log.' + p + '}', response.data[i][p]); |
| 569 | } |
| 570 | } |
| 571 | |
| 572 | $tbody.append('<tr' + (i % 2 ? ' class="alternate"' : '') + '>' + templateCopy + '</tr>'); |
| 573 | } |
| 574 | }); |
| 575 | }; |
| 576 | |
| 577 | $('#fs_filter').click(function () { |
| 578 | loadLogs(); |
| 579 | |
| 580 | return false; |
| 581 | }); |
| 582 | |
| 583 | loadLogs(); |
| 584 | }); |
| 585 | </script> |
| 586 | <?php endif ?> |
| 587 |