PluginProbe
Tiered Pricing Table for WooCommerce / 2.0
Tiered Pricing Table for WooCommerce v2.0
7.1.7 7.1.5 7.1.4 7.1.1 6.5.0 6.4.0 6.1.0 trunk 1.0 1.1 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 All 90 releases
tier-pricing-table / freemius / templates / debug.php

debug.php in Tiered Pricing Table for WooCommerce 2.0, at freemius/templates/debug.php

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