PluginProbe
StreamCast – bring live radio to your site with a sleek player / 2.2.5
StreamCast – bring live radio to your site with a sleek player v2.2.5
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.2.5, at freemius/templates/debug.php

891 lines 40.7 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 )
265 ?>
266 <br>
267 <table class="widefat">
268 <thead>
269 <tr>
270 <th><?php fs_esc_html_echo_inline( 'Key', 'key' ) ?></th>
271 <th><?php fs_esc_html_echo_inline( 'Value', 'value' ) ?></th>
272 </tr>
273 </thead>
274 <tbody>
275 <?php $alternate = false;
276 foreach ( $defines as $p ) : ?>
277 <tr<?php if ( $alternate ) {
278 echo ' class="alternate"';
279 } ?>>
280 <td><?php echo $p['key'] ?></td>
281 <td><?php echo $p['val'] ?></td>
282 </tr>
283 <?php $alternate = ! $alternate ?>
284 <?php endforeach ?>
285 </tbody>
286 </table>
287 <h2><?php fs_esc_html_echo_x_inline( 'SDK Versions', 'as software development kit versions', 'sdk-versions' ) ?></h2>
288 <table id="fs_sdks" class="widefat">
289 <thead>
290 <tr>
291 <th><?php fs_esc_html_echo_x_inline( 'Version', 'product version' ) ?></th>
292 <th><?php fs_esc_html_echo_inline( 'SDK Path' ) ?></th>
293 <th><?php fs_esc_html_echo_inline( 'Module Path' ) ?></th>
294 <th><?php fs_esc_html_echo_inline( 'Is Active' ) ?></th>
295 </tr>
296 </thead>
297 <tbody>
298 <?php foreach ( $fs_active_plugins->plugins as $sdk_path => $data ) : ?>
299 <?php $is_active = ( WP_FS__SDK_VERSION == $data->version ) ?>
300 <tr<?php if ( $is_active ) {
301 echo ' style="background: #E6FFE6; font-weight: bold"';
302 } ?>>
303 <td><?php echo $data->version ?></td>
304 <td><?php echo $sdk_path ?></td>
305 <td><?php echo $data->plugin_path ?></td>
306 <td><?php echo ( $is_active ) ? 'Active' : 'Inactive' ?></td>
307 </tr>
308 <?php endforeach ?>
309 </tbody>
310 </table>
311
312 <?php
313 $module_types = array(
314 WP_FS__MODULE_TYPE_PLUGIN,
315 WP_FS__MODULE_TYPE_THEME
316 );
317 ?>
318 <?php $active_modules_by_id = array() ?>
319 <?php foreach ( $module_types as $module_type ) : ?>
320 <?php $modules = fs_get_entities( $fs_options->get_option( $module_type . 's' ), FS_Plugin::get_class_name() ) ?>
321 <?php if ( is_array( $modules ) && count( $modules ) > 0 ) : ?>
322 <h2><?php echo esc_html( ( WP_FS__MODULE_TYPE_PLUGIN == $module_type ) ? fs_text_inline( 'Plugins', 'plugins' ) : fs_text_inline( 'Themes', 'themes' ) ) ?></h2>
323 <table id="fs_<?php echo $module_type ?>" class="widefat">
324 <thead>
325 <tr>
326 <th><?php fs_esc_html_echo_inline( 'ID', 'id' ) ?></th>
327 <th><?php fs_esc_html_echo_inline( 'Slug' ) ?></th>
328 <th><?php fs_esc_html_echo_x_inline( 'Version', 'product version' ) ?></th>
329 <th><?php fs_esc_html_echo_inline( 'Title' ) ?></th>
330 <th><?php fs_esc_html_echo_x_inline( 'API', 'as application program interface' ) ?></th>
331 <th><?php fs_esc_html_echo_inline( 'Freemius State' ) ?></th>
332 <th><?php fs_esc_html_echo_inline( 'Module Path' ) ?></th>
333 <th><?php fs_esc_html_echo_inline( 'Public Key' ) ?></th>
334 <?php if ( $is_multisite ) : ?>
335 <th><?php fs_esc_html_echo_inline( 'Network Blog' ) ?></th>
336 <th><?php fs_esc_html_echo_inline( 'Network User' ) ?></th>
337 <?php endif ?>
338 <th><?php fs_esc_html_echo_inline( 'Actions' ) ?></th>
339 </tr>
340 </thead>
341 <tbody>
342 <?php foreach ( $modules as $slug => $data ) : ?>
343 <?php
344 if ( WP_FS__MODULE_TYPE_THEME !== $module_type ) {
345 $is_active = is_plugin_active( $data->file );
346 } else {
347 $current_theme = wp_get_theme();
348 $is_active = ( $current_theme->stylesheet === $data->file );
349
350 if ( ! $is_active && is_child_theme() ) {
351 $parent_theme = $current_theme->parent();
352
353 $is_active = ( ( $parent_theme instanceof WP_Theme ) && $parent_theme->stylesheet === $data->file );
354 }
355 }
356 ?>
357 <?php
358 $fs = null;
359 if ( $is_active ) {
360 $fs = freemius( $data->id );
361
362 $active_modules_by_id[ $data->id ] = true;
363 }
364 ?>
365 <tr<?php if ( $is_active ) {
366 $has_api_connectivity = $fs->has_api_connectivity();
367
368 if ( true === $has_api_connectivity && $fs->is_on() ) {
369 echo ' style="background: #E6FFE6; font-weight: bold"';
370 } else {
371 echo ' style="background: #ffd0d0; font-weight: bold"';
372 }
373 } ?>>
374 <td><?php echo $data->id ?></td>
375 <td><?php echo $slug ?></td>
376 <td><?php echo $data->version ?></td>
377 <td><?php echo $data->title ?></td>
378 <td<?php if ( $is_active && true !== $has_api_connectivity ) {
379 echo ' style="color: red; text-transform: uppercase;"';
380 } ?>><?php if ( $is_active ) {
381 echo esc_html( true === $has_api_connectivity ?
382 fs_text_x_inline( 'Connected', 'as connection was successful' ) :
383 ( false === $has_api_connectivity ?
384 fs_text_x_inline( 'Blocked', 'as connection blocked' ) :
385 fs_text_x_inline( 'Unknown', 'API connectivity state is unknown' ) )
386 );
387 } ?></td>
388 <td<?php if ( $is_active && ! $fs->is_on() ) {
389 echo ' style="color: red; text-transform: uppercase;"';
390 } ?>><?php if ( $is_active ) {
391 echo esc_html( $fs->is_on() ?
392 $on_text :
393 $off_text
394 );
395 } ?></td>
396 <td><?php echo $data->file ?></td>
397 <td><?php echo $data->public_key ?></td>
398 <?php if ( $is_multisite ) : ?>
399 <?php
400 $network_blog_id = null;
401 $network_user = null;
402
403 if ( is_object( $fs ) ) {
404 $network_blog_id = $fs->get_network_install_blog_id();
405 $network_user = $fs->get_network_user();
406 }
407 ?>
408 <td><?php echo is_numeric( $network_blog_id ) ? $network_blog_id : '' ?></td>
409 <td><?php if ( is_object( $network_user ) ) {
410 echo $network_user->email;
411 } ?></td>
412 <?php endif ?>
413 <td>
414 <?php if ( $is_active ) : ?>
415 <?php if ( $fs->has_trial_plan() ) : ?>
416 <form action="" method="POST">
417 <input type="hidden" name="fs_action" value="simulate_trial">
418 <input type="hidden" name="module_id" value="<?php echo $fs->get_id() ?>">
419 <?php wp_nonce_field( 'simulate_trial' ) ?>
420
421 <button type="submit" class="button button-primary simulate-trial"><?php fs_esc_html_echo_inline( 'Simulate Trial Promotion' ) ?></button>
422 </form>
423 <?php endif ?>
424 <?php if ( $fs->is_registered() ) : ?>
425 <a class="button" href="<?php echo $fs->get_account_url() ?>"><?php fs_esc_html_echo_inline( 'Account', 'account' ) ?></a>
426 <?php endif ?>
427 <?php if ( fs_is_network_admin() && ! $fs->is_network_upgrade_mode() ) : ?>
428 <form action="" method="POST">
429 <input type="hidden" name="fs_action" value="simulate_network_upgrade">
430 <input type="hidden" name="module_id" value="<?php echo $fs->get_id() ?>">
431 <?php wp_nonce_field( 'simulate_network_upgrade' ) ?>
432
433 <button type="submit" class="button button-small"><?php fs_esc_html_echo_inline( 'Simulate Network Upgrade' ) ?></button>
434 </form>
435 <?php endif ?>
436 <?php endif ?>
437 </td>
438 </tr>
439 <?php endforeach ?>
440 </tbody>
441 </table>
442 <?php endif ?>
443 <?php endforeach ?>
444 <?php foreach ( $module_types as $module_type ) : ?>
445 <?php
446 /**
447 * @var array $VARS
448 * @var array[string]FS_Site|array[string]FS_Site[] $sites_map
449 */
450 $sites_map = $VARS[ $module_type . '_sites' ];
451
452 $all_plans = false;
453 ?>
454 <?php if ( is_array( $sites_map ) && count( $sites_map ) > 0 ) : ?>
455 <h2><?php echo esc_html( sprintf(
456 /* translators: %s: 'plugin' or 'theme' */
457 fs_text_inline( '%s Installs', 'module-installs' ),
458 ( WP_FS__MODULE_TYPE_PLUGIN === $module_type ? fs_text_inline( 'Plugin', 'plugin' ) : fs_text_inline( 'Theme', 'theme' ) )
459 ) ) ?> / <?php fs_esc_html_echo_x_inline( 'Sites', 'like websites', 'sites' ) ?></h2>
460 <table id="fs_<?php echo $module_type ?>_installs" class="widefat">
461 <thead>
462 <tr>
463 <th><?php fs_esc_html_echo_inline( 'ID', 'id' ) ?></th>
464 <?php if ( $is_multisite ) : ?>
465 <th><?php fs_esc_html_echo_inline( 'Blog ID' ) ?></th>
466 <th><?php fs_esc_html_echo_inline( 'Address' ) ?></th>
467 <?php endif ?>
468 <th><?php fs_esc_html_echo_inline( 'Slug' ) ?></th>
469 <th><?php fs_esc_html_echo_inline( 'User ID' ) ?></th>
470 <th><?php fs_esc_html_echo_inline( 'License ID' ) ?></th>
471 <th><?php fs_esc_html_echo_x_inline( 'Plan', 'as product pricing plan', 'plan' ) ?></th>
472 <th><?php fs_esc_html_echo_inline( 'Public Key' ) ?></th>
473 <th><?php fs_esc_html_echo_inline( 'Secret Key' ) ?></th>
474 <th><?php fs_esc_html_echo_inline( 'Actions' ) ?></th>
475 </tr>
476 </thead>
477 <tbody>
478 <?php $site_url = null ?>
479 <?php foreach ( $sites_map as $slug => $sites ) : ?>
480 <?php foreach ( $sites as $site ) : ?>
481 <?php
482 $blog_id = $is_multisite ?
483 $site->blog_id :
484 null;
485
486 if ( is_null( $site_url ) || $is_multisite ) {
487 $site_url = Freemius::get_unfiltered_site_url(
488 $blog_id,
489 true,
490 true
491 );
492 }
493
494 $is_active_clone = ( $site->is_clone( $site_url ) && isset( $active_modules_by_id[ $site->plugin_id ] ) );
495
496 if ( $is_active_clone ) {
497 $has_any_active_clone = true;
498 }
499 ?>
500 <tr>
501 <td>
502 <?php echo $site->id ?>
503 <?php if ( $is_active_clone ) : ?>
504 <label class="fs-tag fs-warn">Clone</label>
505 <?php endif ?>
506 </td>
507 <?php if ( $is_multisite ) : ?>
508 <td><?php echo $blog_id ?></td>
509 <td><?php echo fs_strip_url_protocol( $site->url ) ?></td>
510 <?php endif ?>
511 <td><?php echo $slug ?></td>
512 <td><?php echo $site->user_id ?></td>
513 <td><?php echo !empty($site->license_id) ? $site->license_id : '' ?></td>
514 <td><?php
515 $plan_name = '';
516 if ( FS_Plugin_Plan::is_valid_id( $site->plan_id ) ) {
517 if ( false === $all_plans ) {
518 $option_name = 'plans';
519 if ( WP_FS__MODULE_TYPE_PLUGIN !== $module_type ) {
520 $option_name = $module_type . '_' . $option_name;
521 }
522
523 $all_plans = fs_get_entities( $fs_options->get_option( $option_name, array() ), FS_Plugin_Plan::get_class_name() );
524 }
525
526 foreach ( $all_plans[ $slug ] as $plan ) {
527 $plan_id = Freemius::_decrypt( $plan->id );
528
529 if ( $site->plan_id == $plan_id ) {
530 $plan_name = Freemius::_decrypt( $plan->name );
531 break;
532 }
533 }
534 }
535
536 echo $plan_name;
537 ?></td>
538 <td><?php echo $site->public_key ?></td>
539 <td><?php
540 $plugin_storage = FS_Storage::instance( $module_type, $slug );
541
542 echo $plugin_storage->is_whitelabeled ?
543 FS_Plugin_License::mask_secret_key_for_html( $site->secret_key ) :
544 esc_html( $site->secret_key );
545 ?></td>
546 <td>
547 <form action="" method="POST">
548 <input type="hidden" name="fs_action" value="delete_install">
549 <?php wp_nonce_field( 'delete_install' ) ?>
550 <input type="hidden" name="module_id" value="<?php echo $site->plugin_id ?>">
551 <?php if ( $is_multisite ) : ?>
552 <input type="hidden" name="blog_id" value="<?php echo $site->blog_id ?>">
553 <?php endif ?>
554 <input type="hidden" name="module_type" value="<?php echo $module_type ?>">
555 <input type="hidden" name="slug" value="<?php echo $slug ?>">
556 <button type="submit" class="button"><?php fs_esc_html_echo_x_inline( 'Delete', 'verb', 'delete' ) ?></button>
557 </form>
558 </td>
559 </tr>
560 <?php endforeach ?>
561 <?php endforeach ?>
562 </tbody>
563 </table>
564 <?php endif ?>
565 <?php endforeach ?>
566 <?php
567 $addons = $VARS['addons'];
568 ?>
569 <?php foreach ( $addons as $plugin_id => $plugin_addons ) : ?>
570 <h2><?php echo esc_html( sprintf( fs_text_inline( 'Add Ons of module %s', 'addons-of-x' ), $plugin_id ) ) ?></h2>
571 <table id="fs_addons" class="widefat">
572 <thead>
573 <tr>
574 <th><?php fs_esc_html_echo_inline( 'ID', 'id' ) ?></th>
575 <th><?php fs_esc_html_echo_inline( 'Title' ) ?></th>
576 <th><?php fs_esc_html_echo_inline( 'Slug' ) ?></th>
577 <th><?php fs_esc_html_echo_x_inline( 'Version', 'product version' ) ?></th>
578 <th><?php fs_esc_html_echo_inline( 'Public Key' ) ?></th>
579 <th><?php fs_esc_html_echo_inline( 'Secret Key' ) ?></th>
580 </tr>
581 </thead>
582 <tbody>
583 <?php
584 /**
585 * @var FS_Plugin[] $plugin_addons
586 */
587 foreach ( $plugin_addons as $addon ) : ?>
588 <tr>
589 <td><?php echo $addon->id ?></td>
590 <td><?php echo $addon->title ?></td>
591 <td><?php echo $addon->slug ?></td>
592 <td><?php echo $addon->version ?></td>
593 <td><?php echo $addon->public_key ?></td>
594 <td><?php echo esc_html( $addon->secret_key ) ?></td>
595 </tr>
596 <?php endforeach ?>
597 </tbody>
598 </table>
599 <?php endforeach ?>
600 <?php
601 /**
602 * @var FS_User[] $users
603 */
604 $users = $VARS['users'];
605 $user_ids_map = array();
606 $users_with_developer_license_by_id = array();
607
608 if ( is_array( $users ) && ! empty( $users ) ) {
609 foreach ( $users as $user ) {
610 $user_ids_map[ $user->id ] = true;
611 }
612 }
613
614 foreach ( $module_types as $module_type ) {
615 /**
616 * @var FS_Plugin_License[] $licenses
617 */
618 $licenses = $VARS[ $module_type . '_licenses' ];
619
620 foreach ( $licenses as $license ) {
621 if ( $license->is_whitelabeled ) {
622 $users_with_developer_license_by_id[ $license->user_id ] = true;
623 }
624 }
625 }
626
627 ?>
628 <?php if ( is_array( $users ) && 0 < count( $users ) ) : ?>
629 <h2><?php fs_esc_html_echo_inline( 'Users' ) ?></h2>
630 <table id="fs_users" class="widefat">
631 <thead>
632 <tr>
633 <th><?php fs_esc_html_echo_inline( 'ID', 'id' ) ?></th>
634 <th><?php fs_esc_html_echo_inline( 'Name' ) ?></th>
635 <th><?php fs_esc_html_echo_inline( 'Email' ) ?></th>
636 <th><?php fs_esc_html_echo_inline( 'Verified' ) ?></th>
637 <th><?php fs_esc_html_echo_inline( 'Public Key' ) ?></th>
638 <th><?php fs_esc_html_echo_inline( 'Secret Key' ) ?></th>
639 <th><?php fs_esc_html_echo_inline( 'Actions' ) ?></th>
640 </tr>
641 </thead>
642 <tbody>
643 <?php foreach ( $users as $user_id => $user ) : ?>
644 <?php $has_developer_license = isset( $users_with_developer_license_by_id[ $user_id ] ) ?>
645 <tr>
646 <td><?php echo $user->id ?></td>
647 <td><?php echo $has_developer_license ? '' : $user->get_name() ?></td>
648 <td>
649 <?php if ( ! $has_developer_license ) : ?>
650 <a href="mailto:<?php echo esc_attr( $user->email ) ?>"><?php echo $user->email ?></a>
651 <?php endif ?>
652 </td>
653 <td><?php echo $has_developer_license ? '' : json_encode( $user->is_verified ) ?></td>
654 <td><?php echo $user->public_key ?></td>
655 <td><?php echo $has_developer_license ? FS_Plugin_License::mask_secret_key_for_html($user->secret_key) : esc_html( $user->secret_key ) ?></td>
656 <td>
657 <?php if ( ! $has_developer_license ) : ?>
658 <form action="" method="POST">
659 <input type="hidden" name="fs_action" value="delete_user">
660 <?php wp_nonce_field( 'delete_user' ) ?>
661 <input type="hidden" name="user_id" value="<?php echo $user->id ?>">
662 <button type="submit" class="button"><?php fs_esc_html_echo_x_inline( 'Delete', 'verb', 'delete' ) ?></button>
663 </form>
664 <?php endif ?>
665 </td>
666 </tr>
667 <?php endforeach ?>
668 </tbody>
669 </table>
670 <?php endif ?>
671 <?php foreach ( $module_types as $module_type ) : ?>
672 <?php
673 /**
674 * @var FS_Plugin_License[] $licenses
675 */
676 $licenses = $VARS[ $module_type . '_licenses' ] ?>
677 <?php if ( is_array( $licenses ) && count( $licenses ) > 0 ) : ?>
678 <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>
679 <table id="fs_<?php echo $module_type ?>_licenses" class="widefat">
680 <thead>
681 <tr>
682 <th><?php fs_esc_html_echo_inline( 'ID', 'id' ) ?></th>
683 <th><?php fs_esc_html_echo_inline( 'Plugin ID' ) ?></th>
684 <th><?php fs_esc_html_echo_inline( 'User ID' ) ?></th>
685 <th><?php fs_esc_html_echo_inline( 'Plan ID' ) ?></th>
686 <th><?php fs_esc_html_echo_inline( 'Quota' ) ?></th>
687 <th><?php fs_esc_html_echo_inline( 'Activated' ) ?></th>
688 <th><?php fs_esc_html_echo_inline( 'Blocking' ) ?></th>
689 <th><?php fs_esc_html_echo_inline( 'Type' ) ?></th>
690 <th><?php fs_esc_html_echo_inline( 'License Key' ) ?></th>
691 <th><?php fs_esc_html_echo_x_inline( 'Expiration', 'as expiration date' ) ?></th>
692 </tr>
693 </thead>
694 <tbody>
695 <?php foreach ( $licenses as $license ) : ?>
696 <tr>
697 <td><?php echo $license->id ?></td>
698 <td><?php echo $license->plugin_id ?></td>
699 <td><?php echo $license->user_id ?></td>
700 <td><?php echo $license->plan_id ?></td>
701 <td><?php echo $license->is_unlimited() ? 'Unlimited' : ( $license->is_single_site() ? 'Single Site' : $license->quota ) ?></td>
702 <td><?php echo $license->activated ?></td>
703 <td><?php echo $license->is_block_features ? 'Blocking' : 'Flexible' ?></td>
704 <td><?php echo $license->is_whitelabeled ? 'Whitelabeled' : 'Normal' ?></td>
705 <td><?php
706 echo ( $license->is_whitelabeled || ! isset( $user_ids_map[ $license->user_id ] ) ) ?
707 $license->get_html_escaped_masked_secret_key() :
708 esc_html( $license->secret_key );
709 ?></td>
710 <td><?php echo $license->expiration ?></td>
711 </tr>
712 <?php endforeach ?>
713 </tbody>
714 </table>
715 <?php endif ?>
716 <?php endforeach ?>
717 <?php if ( FS_Logger::is_storage_logging_on() ) : ?>
718
719 <h2><?php fs_esc_html_echo_inline( 'Debug Log', 'debug-log' ) ?></h2>
720
721 <div id="fs_debug_filters">
722 <select name="type">
723 <option value="" selected="selected"><?php fs_esc_html_echo_inline( 'All Types', 'all-types' ) ?></option>
724 <option value="warn_error">Warnings & Errors</option>
725 <option value="error">Errors</option>
726 <option value="warn">Warnings</option>
727 <option value="info">Info</option>
728 </select>
729 <select name="request_type">
730 <option value="" selected="selected"><?php fs_esc_html_echo_inline( 'All Requests', 'all-requests' ) ?></option>
731 <option value="call">Sync</option>
732 <option value="ajax">AJAX</option>
733 <option value="cron">WP Cron</option>
734 </select>
735 <input name="file" type="text" placeholder="<?php fs_esc_attr_echo_inline( 'File' ) ?>"/>
736 <input name="function" type="text" placeholder="<?php fs_esc_attr_echo_inline( 'Function' ) ?>"/>
737 <input name="process_id" type="text" placeholder="<?php fs_esc_attr_echo_inline( 'Process ID' ) ?>"/>
738 <input name="logger" type="text" placeholder="<?php fs_esc_attr_echo_inline( 'Logger' ) ?>"/>
739 <input name="message" type="text" placeholder="<?php fs_esc_attr_echo_inline( 'Message' ) ?>"/>
740 <div style="margin: 10px 0">
741 <button id="fs_filter" class="button" style="float: left"><i class="dashicons dashicons-filter"></i> <?php fs_esc_html_echo_inline( 'Filter', 'filter' ) ?>
742 </button>
743
744 <form action="" method="POST" style="float: left; margin-left: 10px;">
745 <input type="hidden" name="fs_action" value="download_logs">
746 <?php wp_nonce_field( 'download_logs' ) ?>
747 <div class="fs-filters"></div>
748 <button id="fs_download" class="button" type="submit"><i
749 class="dashicons dashicons-download"></i> <?php fs_esc_html_echo_inline( 'Download' ) ?></button>
750 </form>
751 <div style="clear: both"></div>
752 </div>
753 </div>
754
755 <div id="fs_log_book" style="height: 300px; overflow: auto;">
756 <table class="widefat">
757 <thead>
758 <tr>
759 <th>#</th>
760 <th><?php fs_esc_html_echo_inline( 'Type' ) ?></th>
761 <th><?php fs_esc_html_echo_inline( 'ID', 'id' ) ?></th>
762 <th><?php fs_esc_html_echo_inline( 'Function' ) ?></th>
763 <th><?php fs_esc_html_echo_inline( 'Message' ) ?></th>
764 <th><?php fs_esc_html_echo_inline( 'File' ) ?></th>
765 <th><?php fs_esc_html_echo_inline( 'Timestamp' ) ?></th>
766 </tr>
767 </thead>
768 <tbody>
769 <tr style="display: none">
770 <td>{$log.log_order}.</td>
771 <td class="fs-col--type">{$log.type}</td>
772 <td class="fs-col--logger">{$log.logger}</td>
773 <td class="fs-col--function">{$log.function}</td>
774 <td class="fs-col--message">
775 <a href="#" onclick="jQuery(this).parent().find('div').toggle(); return false;">
776 <nobr>{$log.message_short}</nobr>
777 </a>
778 <div style="display: none;">{$log.message}</div>
779 </td>
780 <td class="fs-col--file">{$log.file}:{$log.line}</td>
781 <td class="fs-col--timestamp">{$log.created}</td>
782 </tr>
783
784 </tbody>
785 </table>
786 </div>
787 <script type="text/javascript">
788 jQuery(document).ready(function ($) {
789 var filtersChanged = false,
790 offset = 0,
791 limit = 200,
792 prevFiltersSignature = null;
793
794 var getFilters = function () {
795 var filters = {},
796 signature = '';
797
798 $('#fs_debug_filters').find('select, input').each(function (i, e) {
799 var $element = $(e);
800
801 if ('hidden' === $element.attr('type'))
802 return;
803
804 var val = $element.val();
805 if ('' !== val.trim()) {
806 var name = $(e).attr('name');
807 filters[name] = val;
808 signature += name + '=' + val + '~';
809 }
810 });
811
812 if (signature != prevFiltersSignature) {
813 filtersChanged = true;
814 prevFiltersSignature = signature;
815 } else {
816 filtersChanged = false;
817 }
818
819 return filters;
820 };
821
822 $('#fs_download').parent().submit(function () {
823 var filters = getFilters(),
824 hiddenFields = '';
825
826 for (var f in filters) {
827 if (filters.hasOwnProperty(f)) {
828 hiddenFields += '<input type="hidden" name="filters[' + f + ']" value="' + filters[f] + '" />';
829 }
830 }
831
832 $(this).find('.fs-filters').html(hiddenFields);
833 });
834
835 var loadLogs = function () {
836 var $tbody = $('#fs_log_book tbody'),
837 template = $tbody.find('tr:first-child').html(),
838 filters = getFilters();
839
840 if (!filtersChanged) {
841 offset += limit;
842 } else {
843 // Cleanup table for new filter (only keep template row).
844 $tbody.find('tr').each(function (i, e) {
845 if (0 == i)
846 return;
847
848 $(e).remove();
849 });
850
851 offset = 0;
852 }
853
854 $.post(<?php echo Freemius::ajax_url() ?>, {
855 action : 'fs_get_debug_log',
856 // As such we don't need to use `wp_json_encode` method but using it to follow wp.org guideline.
857 _wpnonce : <?php echo wp_json_encode( wp_create_nonce( 'fs_get_debug_log' ) ); ?>,
858 filters: filters,
859 offset : offset,
860 limit : limit
861 }, function (response) {
862
863 for (var i = 0; i < response.data.length; i++) {
864 var templateCopy = template;
865
866 response.data[i].message_short = (response.data[i].message.length > 32) ?
867 response.data[i].message.substr(0, 32) + '...' :
868 response.data[i].message;
869
870 for (var p in response.data[i]) {
871 if (response.data[i].hasOwnProperty(p)) {
872 templateCopy = templateCopy.replace('{$log.' + p + '}', response.data[i][p]);
873 }
874 }
875
876 $tbody.append('<tr' + (i % 2 ? ' class="alternate"' : '') + '>' + templateCopy + '</tr>');
877 }
878 });
879 };
880
881 $('#fs_filter').click(function () {
882 loadLogs();
883
884 return false;
885 });
886
887 loadLogs();
888 });
889 </script>
890 <?php endif ?>
891