PluginProbe
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites / 2.5.3
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites v2.5.3
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 2.5.3, at freemius/templates/debug.php

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