PluginProbe
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder / 1.4.1
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder v1.4.1
3.6.0 3.5.0 trunk 1.0.10 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.6.1 1.0.7 1.0.8 1.0.9 1.1 1.1.1 1.2 1.3 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5 1.5.1 All 110 releases
buttonizer-multifunctional-button / freemius / templates / debug.php

debug.php in Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder 1.4.1, at freemius/templates/debug.php

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