PluginProbe
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder / 1.5.1
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder v1.5.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.5.1, at freemius/templates/debug.php

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