PluginProbe
StreamCast – bring live radio to your site with a sleek player / 2.3.3
StreamCast – bring live radio to your site with a sleek player v2.3.3
2.4.5 2.4.4 trunk 1.0 1.1 2.0.0 2.1.10 2.1.2 2.1.4 2.1.5 2.1.8 2.2.1 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 All 29 releases
streamcast / freemius / templates / debug.php

debug.php in StreamCast – bring live radio to your site with a sleek player 2.3.3, at freemius/templates/debug.php

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