| @@ -15,18 +15,29 @@ | ||
| 15 | 15 | $fs_options = FS_Options::instance( WP_FS__ACCOUNTS_OPTION_NAME, true ); |
| 16 | 16 | |
| 17 | 17 | $off_text = fs_text_x_inline( 'Off', 'as turned off' ); |
| 18 | 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; | |
| 19 | 28 | ?> |
| 20 | 29 | <h1><?php echo fs_text_inline( 'Freemius Debug' ) . ' - ' . fs_text_inline( 'SDK' ) . ' v.' . $fs_active_plugins->newest->version ?></h1> |
| 21 | 30 | <div> |
| 22 | 31 | <!-- Debugging Switch --> |
| 23 | - <?php //$debug_mode = get_option( 'fs_debug_mode', null ) ?> | |
| 24 | 32 | <span class="fs-switch-label"><?php fs_esc_html_echo_x_inline( 'Debugging', 'as code debugging' ) ?></span> |
| 25 | 33 | |
| 26 | 34 | <div class="fs-switch fs-round <?php echo WP_FS__DEBUG_SDK ? 'fs-on' : 'fs-off' ?>"> |
| 27 | 35 | <div class="fs-toggle"></div> |
| 28 | 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 | + | |
| 29 | 40 | <script type="text/javascript"> |
| 30 | 41 | (function ($) { |
| 31 | 42 | $(document).ready(function () { |
| 32 | 43 | // Switch toggle |
| @@ -34,12 +45,22 @@ | ||
| 34 | 45 | $( this ) |
| 35 | 46 | .toggleClass( 'fs-on' ) |
| 36 | 47 | .toggleClass( 'fs-off' ); |
| 37 | 48 | |
| 38 | - $.post( ajaxurl, { | |
| 49 | + var is_on = ($(this).hasClass( 'fs-on' ) ? 1 : 0); | |
| 50 | + | |
| 51 | + $.post( <?php echo Freemius::ajax_url() ?>, { | |
| 39 | 52 | action: 'fs_toggle_debug_mode', |
| 40 | - is_on : ($(this).hasClass( 'fs-on' ) ? 1 : 0) | |
| 41 | - }, function ( response ) { | |
| 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 | + | |
| 42 | 63 | if ( 1 == response ) { |
| 43 | 64 | // Refresh page on success. |
| 44 | 65 | location.reload(); |
| 45 | 66 | } |
| @@ -44,8 +65,52 @@ | ||
| 44 | 65 | location.reload(); |
| 45 | 66 | } |
| 46 | 67 | }); |
| 47 | 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 | + | |
| 48 | 113 | }); |
| 49 | 114 | }(jQuery)); |
| 50 | 115 | </script> |
| 51 | 116 | </div> |
| @@ -76,9 +141,19 @@ | ||
| 76 | 141 | <?php wp_nonce_field( 'clear_updates_data' ) ?> |
| 77 | 142 | <button class="button"><?php fs_esc_html_echo_inline( 'Clear Updates Transients' ) ?></button> |
| 78 | 143 | </form> |
| 79 | 144 | </td> |
| 145 | + <?php if ( Freemius::is_deactivation_snoozed() ) : ?> | |
| 80 | 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> | |
| 81 | 156 | <!-- Sync Data with Server --> |
| 82 | 157 | <form action="" method="POST"> |
| 83 | 158 | <input type="hidden" name="background_sync" value="true"> |
| 84 | 159 | <button class="button button-primary"><?php fs_esc_html_echo_inline( 'Sync Data From Server' ) ?></button> |
| @@ -99,8 +174,17 @@ | ||
| 99 | 174 | </td> |
| 100 | 175 | <td> |
| 101 | 176 | <button id="fs_set_db_option" class="button"><?php fs_esc_html_echo_inline( 'Set DB Option' ) ?></button> |
| 102 | 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> | |
| 103 | 187 | </tr> |
| 104 | 188 | </tbody> |
| 105 | 189 | </table> |
| 106 | 190 | <script type="text/javascript"> |
| @@ -108,11 +192,12 @@ | ||
| 108 | 192 | $('#fs_load_db_option').click(function () { |
| 109 | 193 | var optionName = prompt('Please enter the option name:'); |
| 110 | 194 | |
| 111 | 195 | if (optionName) { |
| 112 | - $.post(ajaxurl, { | |
| 196 | + $.post(<?php echo Freemius::ajax_url() ?>, { | |
| 113 | 197 | action : 'fs_get_db_option', |
| 114 | - _wpnonce : '<?php echo wp_create_nonce( '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' ) ); ?>, | |
| 115 | 200 | option_name: optionName |
| 116 | 201 | }, function (response) { |
| 117 | 202 | if (response.data.value) |
| 118 | 203 | prompt('The option value is:', response.data.value); |
| @@ -128,11 +213,12 @@ | ||
| 128 | 213 | if (optionName) { |
| 129 | 214 | var optionValue = prompt('Please enter the option value:'); |
| 130 | 215 | |
| 131 | 216 | if (optionValue) { |
| 132 | - $.post(ajaxurl, { | |
| 217 | + $.post(<?php echo Freemius::ajax_url() ?>, { | |
| 133 | 218 | action : 'fs_set_db_option', |
| 134 | - _wpnonce : '<?php echo wp_create_nonce( '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' ) ); ?>, | |
| 135 | 221 | option_name : optionName, |
| 136 | 222 | option_value: optionValue |
| 137 | 223 | }, function () { |
| 138 | 224 | alert('Option was successfully set.'); |
| @@ -170,8 +256,20 @@ | ||
| 170 | 256 | array( |
| 171 | 257 | 'key' => 'WP_FS__DIR', |
| 172 | 258 | 'val' => WP_FS__DIR, |
| 173 | 259 | ), |
| 260 | + array( | |
| 261 | + 'key' => 'DISABLE_WP_CRON', | |
| 262 | + 'val' => defined( 'DISABLE_WP_CRON' ) ? ( DISABLE_WP_CRON ? 'true' : 'false' ) : 'Not defined', | |
| 263 | + ), | |
| 264 | + array( | |
| 265 | + 'key' => 'wp_using_ext_object_cache()', | |
| 266 | + 'val' => wp_using_ext_object_cache() ? 'true' : 'false', | |
| 267 | + ), | |
| 268 | + array( | |
| 269 | + 'key' => 'Freemius::get_unfiltered_site_url()', | |
| 270 | + 'val' => Freemius::get_unfiltered_site_url(), | |
| 271 | + ), | |
| 174 | 272 | ) |
| 175 | 273 | ?> |
| 176 | 274 | <br> |
| 177 | 275 | <table class="widefat"> |
| @@ -187,16 +285,25 @@ | ||
| 187 | 285 | <tr<?php if ( $alternate ) { |
| 188 | 286 | echo ' class="alternate"'; |
| 189 | 287 | } ?>> |
| 190 | 288 | <td><?php echo $p['key'] ?></td> |
| 191 | - <td><?php echo $p['val'] ?></td> | |
| 289 | + <td><?php echo $p['val'] ?><?php | |
| 290 | + if ( 'DISABLE_WP_CRON' === $p['key'] && 'true' === $p['val'] ) { | |
| 291 | + echo '<p><small><strong>Freemius SDK’s sync cron jobs will not run unless an alternative server-side cron is set up.</strong></small></p>'; | |
| 292 | + } | |
| 293 | + ?></td> | |
| 192 | 294 | </tr> |
| 193 | 295 | <?php $alternate = ! $alternate ?> |
| 194 | 296 | <?php endforeach ?> |
| 195 | 297 | </tbody> |
| 196 | 298 | </table> |
| 197 | -<h2><?php fs_esc_html_echo_x_inline( 'SDK Versions', 'as software development kit versions', 'sdk-versions' ) ?></h2> | |
| 198 | -<table id="fs_sdks" class="widefat"> | |
| 299 | +<h2> | |
| 300 | + <button class="fs-debug-table-toggle-button" aria-expanded="true"> | |
| 301 | + <span class="fs-debug-table-toggle-icon">▼</span> | |
| 302 | + </button> | |
| 303 | + <?php fs_esc_html_echo_x_inline( 'SDK Versions', 'as software development kit versions', 'sdk-versions' ) ?> | |
| 304 | +</h2> | |
| 305 | +<table id="fs_sdks" class="widefat fs-debug-table"> | |
| 199 | 306 | <thead> |
| 200 | 307 | <tr> |
| 201 | 308 | <th><?php fs_esc_html_echo_x_inline( 'Version', 'product version' ) ?></th> |
| 202 | 309 | <th><?php fs_esc_html_echo_inline( 'SDK Path' ) ?></th> |
| @@ -224,14 +331,19 @@ | ||
| 224 | 331 | WP_FS__MODULE_TYPE_PLUGIN, |
| 225 | 332 | WP_FS__MODULE_TYPE_THEME |
| 226 | 333 | ); |
| 227 | 334 | ?> |
| 228 | - | |
| 335 | +<?php $active_modules_by_id = array() ?> | |
| 229 | 336 | <?php foreach ( $module_types as $module_type ) : ?> |
| 230 | 337 | <?php $modules = fs_get_entities( $fs_options->get_option( $module_type . 's' ), FS_Plugin::get_class_name() ) ?> |
| 231 | 338 | <?php if ( is_array( $modules ) && count( $modules ) > 0 ) : ?> |
| 232 | - <h2><?php echo esc_html( ( WP_FS__MODULE_TYPE_PLUGIN == $module_type ) ? fs_text_inline( 'Plugins', 'plugins' ) : fs_text_inline( 'Themes', 'themes' ) ) ?></h2> | |
| 233 | - <table id="fs_<?php echo $module_type ?>" class="widefat"> | |
| 339 | + <h2> | |
| 340 | + <button class="fs-debug-table-toggle-button" aria-expanded="true"> | |
| 341 | + <span class="fs-debug-table-toggle-icon">▼</span> | |
| 342 | + </button> | |
| 343 | + <?php echo esc_html( ( WP_FS__MODULE_TYPE_PLUGIN == $module_type ) ? fs_text_inline( 'Plugins', 'plugins' ) : fs_text_inline( 'Themes', 'themes' ) ) ?> | |
| 344 | + </h2> | |
| 345 | + <table id="fs_<?php echo $module_type ?>" class="widefat fs-debug-table"> | |
| 234 | 346 | <thead> |
| 235 | 347 | <tr> |
| 236 | 348 | <th><?php fs_esc_html_echo_inline( 'ID', 'id' ) ?></th> |
| 237 | 349 | <th><?php fs_esc_html_echo_inline( 'Slug' ) ?></th> |
| @@ -240,9 +352,9 @@ | ||
| 240 | 352 | <th><?php fs_esc_html_echo_x_inline( 'API', 'as application program interface' ) ?></th> |
| 241 | 353 | <th><?php fs_esc_html_echo_inline( 'Freemius State' ) ?></th> |
| 242 | 354 | <th><?php fs_esc_html_echo_inline( 'Module Path' ) ?></th> |
| 243 | 355 | <th><?php fs_esc_html_echo_inline( 'Public Key' ) ?></th> |
| 244 | - <?php if ( is_multisite() ) : ?> | |
| 356 | + <?php if ( $is_multisite ) : ?> | |
| 245 | 357 | <th><?php fs_esc_html_echo_inline( 'Network Blog' ) ?></th> |
| 246 | 358 | <th><?php fs_esc_html_echo_inline( 'Network User' ) ?></th> |
| 247 | 359 | <?php endif ?> |
| 248 | 360 | <th><?php fs_esc_html_echo_inline( 'Actions' ) ?></th> |
| @@ -248,8 +360,9 @@ | ||
| 248 | 360 | <th><?php fs_esc_html_echo_inline( 'Actions' ) ?></th> |
| 249 | 361 | </tr> |
| 250 | 362 | </thead> |
| 251 | 363 | <tbody> |
| 364 | + <?php $alternate = false; ?> | |
| 252 | 365 | <?php foreach ( $modules as $slug => $data ) : ?> |
| 253 | 366 | <?php |
| 254 | 367 | if ( WP_FS__MODULE_TYPE_THEME !== $module_type ) { |
| 255 | 368 | $is_active = is_plugin_active( $data->file ); |
| @@ -263,13 +376,22 @@ | ||
| 263 | 376 | $is_active = ( ( $parent_theme instanceof WP_Theme ) && $parent_theme->stylesheet === $data->file ); |
| 264 | 377 | } |
| 265 | 378 | } |
| 266 | 379 | ?> |
| 267 | - <?php $fs = $is_active ? freemius( $data->id ) : null ?> | |
| 268 | - <tr<?php if ( $is_active ) { | |
| 269 | - if ( $fs->has_api_connectivity() && $fs->is_on() ) { | |
| 380 | + <?php | |
| 381 | + $fs = null; | |
| 382 | + if ( $is_active ) { | |
| 383 | + $fs = freemius( $data->id ); | |
| 384 | + | |
| 385 | + $active_modules_by_id[ $data->id ] = true; | |
| 386 | + } | |
| 387 | + ?> | |
| 388 | + <tr<?php if ( $alternate ) { echo ' class="alternate" '; } ?><?php if ( $is_active ) { | |
| 389 | + $has_api_connectivity = $fs->has_api_connectivity(); | |
| 390 | + | |
| 391 | + if ( true === $has_api_connectivity && $fs->is_on() ) { | |
| 270 | 392 | echo ' style="background: #E6FFE6; font-weight: bold"'; |
| 271 | - } else { | |
| 393 | + } else if ( false === $has_api_connectivity || ! $fs->is_on() ) { | |
| 272 | 394 | echo ' style="background: #ffd0d0; font-weight: bold"'; |
| 273 | 395 | } |
| 274 | 396 | } ?>> |
| 275 | 397 | <td><?php echo $data->id ?></td> |
| @@ -275,14 +397,16 @@ | ||
| 275 | 397 | <td><?php echo $data->id ?></td> |
| 276 | 398 | <td><?php echo $slug ?></td> |
| 277 | 399 | <td><?php echo $data->version ?></td> |
| 278 | 400 | <td><?php echo $data->title ?></td> |
| 279 | - <td<?php if ( $is_active && ! $fs->has_api_connectivity() ) { | |
| 401 | + <td<?php if ( $is_active && false === $has_api_connectivity ) { | |
| 280 | 402 | echo ' style="color: red; text-transform: uppercase;"'; |
| 281 | 403 | } ?>><?php if ( $is_active ) { |
| 282 | - echo esc_html( $fs->has_api_connectivity() ? | |
| 404 | + echo esc_html( true === $has_api_connectivity ? | |
| 283 | 405 | fs_text_x_inline( 'Connected', 'as connection was successful' ) : |
| 284 | - fs_text_x_inline( 'Blocked', 'as connection blocked' ) | |
| 406 | + ( false === $has_api_connectivity ? | |
| 407 | + fs_text_x_inline( 'Blocked', 'as connection blocked' ) : | |
| 408 | + fs_text_x_inline( 'No requests yet', 'API connectivity state is unknown' ) ) | |
| 285 | 409 | ); |
| 286 | 410 | } ?></td> |
| 287 | 411 | <td<?php if ( $is_active && ! $fs->is_on() ) { |
| 288 | 412 | echo ' style="color: red; text-transform: uppercase;"'; |
| @@ -293,9 +417,9 @@ | ||
| 293 | 417 | ); |
| 294 | 418 | } ?></td> |
| 295 | 419 | <td><?php echo $data->file ?></td> |
| 296 | 420 | <td><?php echo $data->public_key ?></td> |
| 297 | - <?php if ( is_multisite() ) : ?> | |
| 421 | + <?php if ( $is_multisite ) : ?> | |
| 298 | 422 | <?php |
| 299 | 423 | $network_blog_id = null; |
| 300 | 424 | $network_user = null; |
| 301 | 425 | |
| @@ -334,8 +458,9 @@ | ||
| 334 | 458 | <?php endif ?> |
| 335 | 459 | <?php endif ?> |
| 336 | 460 | </td> |
| 337 | 461 | </tr> |
| 462 | + <?php $alternate = ! $alternate ?> | |
| 338 | 463 | <?php endforeach ?> |
| 339 | 464 | </tbody> |
| 340 | 465 | </table> |
| 341 | 466 | <?php endif ?> |
| @@ -347,18 +472,22 @@ | ||
| 347 | 472 | * @var array[string]FS_Site|array[string]FS_Site[] $sites_map |
| 348 | 473 | */ |
| 349 | 474 | $sites_map = $VARS[ $module_type . '_sites' ]; |
| 350 | 475 | |
| 351 | - $is_multisite = is_multisite(); | |
| 352 | - $all_plans = false; | |
| 476 | + $all_plans = false; | |
| 353 | 477 | ?> |
| 354 | 478 | <?php if ( is_array( $sites_map ) && count( $sites_map ) > 0 ) : ?> |
| 355 | - <h2><?php echo esc_html( sprintf( | |
| 479 | + <h2> | |
| 480 | + <button class="fs-debug-table-toggle-button" aria-expanded="true"> | |
| 481 | + <span class="fs-debug-table-toggle-icon">▼</span> | |
| 482 | + </button> | |
| 483 | + <?php echo esc_html( sprintf( | |
| 356 | 484 | /* translators: %s: 'plugin' or 'theme' */ |
| 357 | 485 | fs_text_inline( '%s Installs', 'module-installs' ), |
| 358 | 486 | ( WP_FS__MODULE_TYPE_PLUGIN === $module_type ? fs_text_inline( 'Plugin', 'plugin' ) : fs_text_inline( 'Theme', 'theme' ) ) |
| 359 | - ) ) ?> / <?php fs_esc_html_echo_x_inline( 'Sites', 'like websites', 'sites' ) ?></h2> | |
| 360 | - <table id="fs_<?php echo $module_type ?>_installs" class="widefat"> | |
| 487 | + ) ) ?> / <?php fs_esc_html_echo_x_inline( 'Sites', 'like websites', 'sites' ) ?> | |
| 488 | + </h2> | |
| 489 | + <table id="fs_<?php echo $module_type ?>_installs" class="widefat fs-debug-table"> | |
| 361 | 490 | <thead> |
| 362 | 491 | <tr> |
| 363 | 492 | <th><?php fs_esc_html_echo_inline( 'ID', 'id' ) ?></th> |
| 364 | 493 | <?php if ( $is_multisite ) : ?> |
| @@ -374,17 +503,39 @@ | ||
| 374 | 503 | <th><?php fs_esc_html_echo_inline( 'Actions' ) ?></th> |
| 375 | 504 | </tr> |
| 376 | 505 | </thead> |
| 377 | 506 | <tbody> |
| 507 | + <?php $site_url = null ?> | |
| 378 | 508 | <?php foreach ( $sites_map as $slug => $sites ) : ?> |
| 379 | - <?php if ( ! is_array( $sites ) ) { | |
| 380 | - $sites = array( $sites ); | |
| 381 | - } ?> | |
| 382 | 509 | <?php foreach ( $sites as $site ) : ?> |
| 510 | + <?php | |
| 511 | + $blog_id = $is_multisite ? | |
| 512 | + $site->blog_id : | |
| 513 | + null; | |
| 514 | + | |
| 515 | + if ( is_null( $site_url ) || $is_multisite ) { | |
| 516 | + $site_url = Freemius::get_unfiltered_site_url( | |
| 517 | + $blog_id, | |
| 518 | + true, | |
| 519 | + true | |
| 520 | + ); | |
| 521 | + } | |
| 522 | + | |
| 523 | + $is_active_clone = ( $site->is_clone( $site_url ) && isset( $active_modules_by_id[ $site->plugin_id ] ) ); | |
| 524 | + | |
| 525 | + if ( $is_active_clone ) { | |
| 526 | + $has_any_active_clone = true; | |
| 527 | + } | |
| 528 | + ?> | |
| 383 | 529 | <tr> |
| 384 | - <td><?php echo $site->id ?></td> | |
| 530 | + <td> | |
| 531 | + <?php echo $site->id ?> | |
| 532 | + <?php if ( $is_active_clone ) : ?> | |
| 533 | + <label class="fs-tag fs-warn">Clone</label> | |
| 534 | + <?php endif ?> | |
| 535 | + </td> | |
| 385 | 536 | <?php if ( $is_multisite ) : ?> |
| 386 | - <td><?php echo $site->blog_id ?></td> | |
| 537 | + <td><?php echo $blog_id ?></td> | |
| 387 | 538 | <td><?php echo fs_strip_url_protocol( $site->url ) ?></td> |
| 388 | 539 | <?php endif ?> |
| 389 | 540 | <td><?php echo $slug ?></td> |
| 390 | 541 | <td><?php echo $site->user_id ?></td> |
| @@ -444,10 +595,15 @@ | ||
| 444 | 595 | <?php |
| 445 | 596 | $addons = $VARS['addons']; |
| 446 | 597 | ?> |
| 447 | 598 | <?php foreach ( $addons as $plugin_id => $plugin_addons ) : ?> |
| 448 | - <h2><?php echo esc_html( sprintf( fs_text_inline( 'Add Ons of module %s', 'addons-of-x' ), $plugin_id ) ) ?></h2> | |
| 449 | - <table id="fs_addons" class="widefat"> | |
| 599 | + <h2> | |
| 600 | + <button class="fs-debug-table-toggle-button" aria-expanded="true"> | |
| 601 | + <span class="fs-debug-table-toggle-icon">▼</span> | |
| 602 | + </button> | |
| 603 | + <?php echo esc_html( sprintf( fs_text_inline( 'Add Ons of module %s', 'addons-of-x' ), $plugin_id ) ) ?> | |
| 604 | + </h2> | |
| 605 | + <table id="fs_addons" class="widefat fs-debug-table"> | |
| 450 | 606 | <thead> |
| 451 | 607 | <tr> |
| 452 | 608 | <th><?php fs_esc_html_echo_inline( 'ID', 'id' ) ?></th> |
| 453 | 609 | <th><?php fs_esc_html_echo_inline( 'Title' ) ?></th> |
| @@ -479,10 +635,17 @@ | ||
| 479 | 635 | /** |
| 480 | 636 | * @var FS_User[] $users |
| 481 | 637 | */ |
| 482 | 638 | $users = $VARS['users']; |
| 639 | + $user_ids_map = array(); | |
| 483 | 640 | $users_with_developer_license_by_id = array(); |
| 484 | 641 | |
| 642 | + if ( is_array( $users ) && ! empty( $users ) ) { | |
| 643 | + foreach ( $users as $user ) { | |
| 644 | + $user_ids_map[ $user->id ] = true; | |
| 645 | + } | |
| 646 | + } | |
| 647 | + | |
| 485 | 648 | foreach ( $module_types as $module_type ) { |
| 486 | 649 | /** |
| 487 | 650 | * @var FS_Plugin_License[] $licenses |
| 488 | 651 | */ |
| @@ -496,10 +659,15 @@ | ||
| 496 | 659 | } |
| 497 | 660 | |
| 498 | 661 | ?> |
| 499 | 662 | <?php if ( is_array( $users ) && 0 < count( $users ) ) : ?> |
| 500 | - <h2><?php fs_esc_html_echo_inline( 'Users' ) ?></h2> | |
| 501 | - <table id="fs_users" class="widefat"> | |
| 663 | + <h2> | |
| 664 | + <button class="fs-debug-table-toggle-button" aria-expanded="true"> | |
| 665 | + <span class="fs-debug-table-toggle-icon">▼</span> | |
| 666 | + </button> | |
| 667 | + <?php fs_esc_html_echo_inline( 'Users' ) ?> | |
| 668 | + </h2> | |
| 669 | + <table id="fs_users" class="widefat fs-debug-table"> | |
| 502 | 670 | <thead> |
| 503 | 671 | <tr> |
| 504 | 672 | <th><?php fs_esc_html_echo_inline( 'ID', 'id' ) ?></th> |
| 505 | 673 | <th><?php fs_esc_html_echo_inline( 'Name' ) ?></th> |
| @@ -545,10 +713,15 @@ | ||
| 545 | 713 | * @var FS_Plugin_License[] $licenses |
| 546 | 714 | */ |
| 547 | 715 | $licenses = $VARS[ $module_type . '_licenses' ] ?> |
| 548 | 716 | <?php if ( is_array( $licenses ) && count( $licenses ) > 0 ) : ?> |
| 549 | - <h2><?php echo esc_html( sprintf( fs_text_inline( '%s Licenses', 'module-licenses' ), ( WP_FS__MODULE_TYPE_PLUGIN === $module_type ? fs_text_inline( 'Plugin', 'plugin' ) : fs_text_inline( 'Theme', 'theme' ) ) ) ) ?></h2> | |
| 550 | - <table id="fs_<?php echo $module_type ?>_licenses" class="widefat"> | |
| 717 | + <h2> | |
| 718 | + <button class="fs-debug-table-toggle-button" aria-expanded="true"> | |
| 719 | + <span class="fs-debug-table-toggle-icon">▼</span> | |
| 720 | + </button> | |
| 721 | + <?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' ) ) ) ) ?> | |
| 722 | + </h2> | |
| 723 | + <table id="fs_<?php echo $module_type ?>_licenses" class="widefat fs-debug-table"> | |
| 551 | 724 | <thead> |
| 552 | 725 | <tr> |
| 553 | 726 | <th><?php fs_esc_html_echo_inline( 'ID', 'id' ) ?></th> |
| 554 | 727 | <th><?php fs_esc_html_echo_inline( 'Plugin ID' ) ?></th> |
| @@ -573,9 +746,9 @@ | ||
| 573 | 746 | <td><?php echo $license->activated ?></td> |
| 574 | 747 | <td><?php echo $license->is_block_features ? 'Blocking' : 'Flexible' ?></td> |
| 575 | 748 | <td><?php echo $license->is_whitelabeled ? 'Whitelabeled' : 'Normal' ?></td> |
| 576 | 749 | <td><?php |
| 577 | - echo $license->is_whitelabeled ? | |
| 750 | + echo ( $license->is_whitelabeled || ! isset( $user_ids_map[ $license->user_id ] ) ) ? | |
| 578 | 751 | $license->get_html_escaped_masked_secret_key() : |
| 579 | 752 | esc_html( $license->secret_key ); |
| 580 | 753 | ?></td> |
| 581 | 754 | <td><?php echo $license->expiration ?></td> |
| @@ -584,8 +757,12 @@ | ||
| 584 | 757 | </tbody> |
| 585 | 758 | </table> |
| 586 | 759 | <?php endif ?> |
| 587 | 760 | <?php endforeach ?> |
| 761 | +<?php | |
| 762 | + $page_params = array( 'is_fs_debug_page' => true ); | |
| 763 | + fs_require_template( 'debug/scheduled-crons.php', $page_params ); | |
| 764 | +?> | |
| 588 | 765 | <?php if ( FS_Logger::is_storage_logging_on() ) : ?> |
| 589 | 766 | |
| 590 | 767 | <h2><?php fs_esc_html_echo_inline( 'Debug Log', 'debug-log' ) ?></h2> |
| 591 | 768 | |
| @@ -721,10 +898,12 @@ | ||
| 721 | 898 | |
| 722 | 899 | offset = 0; |
| 723 | 900 | } |
| 724 | 901 | |
| 725 | - $.post(ajaxurl, { | |
| 902 | + $.post(<?php echo Freemius::ajax_url() ?>, { | |
| 726 | 903 | action : 'fs_get_debug_log', |
| 904 | + // As such we don't need to use `wp_json_encode` method but using it to follow wp.org guideline. | |
| 905 | + _wpnonce : <?php echo wp_json_encode( wp_create_nonce( 'fs_get_debug_log' ) ); ?>, | |
| 727 | 906 | filters: filters, |
| 728 | 907 | offset : offset, |
| 729 | 908 | limit : limit |
| 730 | 909 | }, function (response) { |
| @@ -756,4 +935,25 @@ | ||
| 756 | 935 | loadLogs(); |
| 757 | 936 | }); |
| 758 | 937 | </script> |
| 759 | 938 | <?php endif ?> |
| 939 | +<script type="text/javascript"> | |
| 940 | + // JavaScript to toggle the visibility of the table body and change the caret icon | |
| 941 | + jQuery( document ).ready( function ( $ ) { | |
| 942 | + $( '.fs-debug-table-toggle-button' ).on( 'click', function () { | |
| 943 | + const button = $( this ); | |
| 944 | + const table = button.closest( 'h2' ).next( 'table' ); | |
| 945 | + const isExpanded = ( 'false' === button.attr( 'aria-expanded' ) ); | |
| 946 | + | |
| 947 | + button.attr( 'aria-expanded', isExpanded ); | |
| 948 | + button.find( '.fs-debug-table-toggle-icon' ).text( isExpanded ? '▼' : '▶' ); | |
| 949 | + | |
| 950 | + table.css( { | |
| 951 | + display : isExpanded ? 'table' : 'block', | |
| 952 | + borderBottomWidth: isExpanded ? '1px' : '0', | |
| 953 | + maxHeight : isExpanded ? 'auto' : '0', | |
| 954 | + } ); | |
| 955 | + } ); | |
| 956 | + | |
| 957 | + $( '.fs-debug-table-toggle-button:last' ).click(); | |
| 958 | + } ); | |
| 959 | +</script> | |