PluginProbe
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites / 1.2.2
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites v1.2.2
4.1.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.1.2 2.5.0 2.5.3 2.6.1 All 38 releases
blockspare / freemius / templates / debug.php

debug.php in BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites 1.2.2, at freemius/templates/debug.php

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