| @@ -15,39 +15,102 @@ | ||
| 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 | - <span class="switch-label"><?php fs_esc_html_echo_x_inline( 'Debugging', 'as code debugging' ) ?></span> | |
| 32 | + <span class="fs-switch-label"><?php fs_esc_html_echo_x_inline( 'Debugging', 'as code debugging' ) ?></span> | |
| 25 | 33 | |
| 26 | - <div class="switch <?php echo WP_FS__DEBUG_SDK ? 'off' : 'on' ?>"> | |
| 27 | - <div class="toggle"></div> | |
| 28 | - <span class="on"><?php echo esc_html( $on_text ) ?></span> | |
| 29 | - <span class="off"><?php echo esc_html( $off_text ) ?></span> | |
| 34 | + <div class="fs-switch fs-round <?php echo WP_FS__DEBUG_SDK ? 'fs-on' : 'fs-off' ?>"> | |
| 35 | + <div class="fs-toggle"></div> | |
| 30 | 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 | + | |
| 31 | 40 | <script type="text/javascript"> |
| 32 | 41 | (function ($) { |
| 33 | 42 | $(document).ready(function () { |
| 34 | 43 | // Switch toggle |
| 35 | - $('.switch').click(function () { | |
| 36 | - $(this) | |
| 37 | - .toggleClass('on') | |
| 38 | - .toggleClass('off'); | |
| 44 | + $( '.fs-switch' ).click( function () { | |
| 45 | + $( this ) | |
| 46 | + .toggleClass( 'fs-on' ) | |
| 47 | + .toggleClass( 'fs-off' ); | |
| 39 | 48 | |
| 40 | - $.post(ajaxurl, { | |
| 49 | + var is_on = ($(this).hasClass( 'fs-on' ) ? 1 : 0); | |
| 50 | + | |
| 51 | + $.post( <?php echo Freemius::ajax_url() ?>, { | |
| 41 | 52 | action: 'fs_toggle_debug_mode', |
| 42 | - is_on : ($(this).hasClass('off') ? 1 : 0) | |
| 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 | |
| 43 | 56 | }, function (response) { |
| 44 | - if (1 == response) { | |
| 57 | + if (is_on) { | |
| 58 | + startCountdownManually(); | |
| 59 | + } else { | |
| 60 | + stopCountdownManually(); | |
| 61 | + } | |
| 62 | + | |
| 63 | + if ( 1 == response ) { | |
| 45 | 64 | // Refresh page on success. |
| 46 | 65 | location.reload(); |
| 47 | 66 | } |
| 48 | 67 | }); |
| 49 | 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 | + | |
| 50 | 113 | }); |
| 51 | 114 | }(jQuery)); |
| 52 | 115 | </script> |
| 53 | 116 | </div> |
| @@ -78,9 +141,19 @@ | ||
| 78 | 141 | <?php wp_nonce_field( 'clear_updates_data' ) ?> |
| 79 | 142 | <button class="button"><?php fs_esc_html_echo_inline( 'Clear Updates Transients' ) ?></button> |
| 80 | 143 | </form> |
| 81 | 144 | </td> |
| 145 | + <?php if ( Freemius::is_deactivation_snoozed() ) : ?> | |
| 82 | 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> | |
| 83 | 156 | <!-- Sync Data with Server --> |
| 84 | 157 | <form action="" method="POST"> |
| 85 | 158 | <input type="hidden" name="background_sync" value="true"> |
| 86 | 159 | <button class="button button-primary"><?php fs_esc_html_echo_inline( 'Sync Data From Server' ) ?></button> |
| @@ -85,14 +158,33 @@ | ||
| 85 | 158 | <input type="hidden" name="background_sync" value="true"> |
| 86 | 159 | <button class="button button-primary"><?php fs_esc_html_echo_inline( 'Sync Data From Server' ) ?></button> |
| 87 | 160 | </form> |
| 88 | 161 | </td> |
| 162 | + <?php if ( fs_is_network_admin() && true !== $fs_options->get_option( 'ms_migration_complete', false, true ) ) : ?> | |
| 89 | 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> | |
| 90 | 173 | <button id="fs_load_db_option" class="button"><?php fs_esc_html_echo_inline( 'Load DB Option' ) ?></button> |
| 91 | 174 | </td> |
| 92 | 175 | <td> |
| 93 | 176 | <button id="fs_set_db_option" class="button"><?php fs_esc_html_echo_inline( 'Set DB Option' ) ?></button> |
| 94 | 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> | |
| 95 | 187 | </tr> |
| 96 | 188 | </tbody> |
| 97 | 189 | </table> |
| 98 | 190 | <script type="text/javascript"> |
| @@ -100,10 +192,12 @@ | ||
| 100 | 192 | $('#fs_load_db_option').click(function () { |
| 101 | 193 | var optionName = prompt('Please enter the option name:'); |
| 102 | 194 | |
| 103 | 195 | if (optionName) { |
| 104 | - $.post(ajaxurl, { | |
| 196 | + $.post(<?php echo Freemius::ajax_url() ?>, { | |
| 105 | 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' ) ); ?>, | |
| 106 | 200 | option_name: optionName |
| 107 | 201 | }, function (response) { |
| 108 | 202 | if (response.data.value) |
| 109 | 203 | prompt('The option value is:', response.data.value); |
| @@ -119,10 +213,12 @@ | ||
| 119 | 213 | if (optionName) { |
| 120 | 214 | var optionValue = prompt('Please enter the option value:'); |
| 121 | 215 | |
| 122 | 216 | if (optionValue) { |
| 123 | - $.post(ajaxurl, { | |
| 217 | + $.post(<?php echo Freemius::ajax_url() ?>, { | |
| 124 | 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' ) ); ?>, | |
| 125 | 221 | option_name : optionName, |
| 126 | 222 | option_value: optionValue |
| 127 | 223 | }, function () { |
| 128 | 224 | alert('Option was successfully set.'); |
| @@ -160,8 +256,12 @@ | ||
| 160 | 256 | array( |
| 161 | 257 | 'key' => 'WP_FS__DIR', |
| 162 | 258 | 'val' => WP_FS__DIR, |
| 163 | 259 | ), |
| 260 | + array( | |
| 261 | + 'key' => 'wp_using_ext_object_cache()', | |
| 262 | + 'val' => wp_using_ext_object_cache() ? 'true' : 'false', | |
| 263 | + ), | |
| 164 | 264 | ) |
| 165 | 265 | ?> |
| 166 | 266 | <br> |
| 167 | 267 | <table class="widefat"> |
| @@ -194,9 +294,9 @@ | ||
| 194 | 294 | <th><?php fs_esc_html_echo_inline( 'Is Active' ) ?></th> |
| 195 | 295 | </tr> |
| 196 | 296 | </thead> |
| 197 | 297 | <tbody> |
| 198 | - <?php foreach ( $fs_active_plugins->plugins as $sdk_path => &$data ) : ?> | |
| 298 | + <?php foreach ( $fs_active_plugins->plugins as $sdk_path => $data ) : ?> | |
| 199 | 299 | <?php $is_active = ( WP_FS__SDK_VERSION == $data->version ) ?> |
| 200 | 300 | <tr<?php if ( $is_active ) { |
| 201 | 301 | echo ' style="background: #E6FFE6; font-weight: bold"'; |
| 202 | 302 | } ?>> |
| @@ -214,11 +314,11 @@ | ||
| 214 | 314 | WP_FS__MODULE_TYPE_PLUGIN, |
| 215 | 315 | WP_FS__MODULE_TYPE_THEME |
| 216 | 316 | ); |
| 217 | 317 | ?> |
| 218 | - | |
| 318 | +<?php $active_modules_by_id = array() ?> | |
| 219 | 319 | <?php foreach ( $module_types as $module_type ) : ?> |
| 220 | - <?php $modules = $fs_options->get_option( $module_type . 's' ) ?> | |
| 320 | + <?php $modules = fs_get_entities( $fs_options->get_option( $module_type . 's' ), FS_Plugin::get_class_name() ) ?> | |
| 221 | 321 | <?php if ( is_array( $modules ) && count( $modules ) > 0 ) : ?> |
| 222 | 322 | <h2><?php echo esc_html( ( WP_FS__MODULE_TYPE_PLUGIN == $module_type ) ? fs_text_inline( 'Plugins', 'plugins' ) : fs_text_inline( 'Themes', 'themes' ) ) ?></h2> |
| 223 | 323 | <table id="fs_<?php echo $module_type ?>" class="widefat"> |
| 224 | 324 | <thead> |
| @@ -230,9 +330,9 @@ | ||
| 230 | 330 | <th><?php fs_esc_html_echo_x_inline( 'API', 'as application program interface' ) ?></th> |
| 231 | 331 | <th><?php fs_esc_html_echo_inline( 'Freemius State' ) ?></th> |
| 232 | 332 | <th><?php fs_esc_html_echo_inline( 'Module Path' ) ?></th> |
| 233 | 333 | <th><?php fs_esc_html_echo_inline( 'Public Key' ) ?></th> |
| 234 | - <?php if ( is_multisite() ) : ?> | |
| 334 | + <?php if ( $is_multisite ) : ?> | |
| 235 | 335 | <th><?php fs_esc_html_echo_inline( 'Network Blog' ) ?></th> |
| 236 | 336 | <th><?php fs_esc_html_echo_inline( 'Network User' ) ?></th> |
| 237 | 337 | <?php endif ?> |
| 238 | 338 | <th><?php fs_esc_html_echo_inline( 'Actions' ) ?></th> |
| @@ -240,18 +340,33 @@ | ||
| 240 | 340 | </thead> |
| 241 | 341 | <tbody> |
| 242 | 342 | <?php foreach ( $modules as $slug => $data ) : ?> |
| 243 | 343 | <?php |
| 244 | - if ( WP_FS__MODULE_TYPE_THEME === $module_type ) { | |
| 344 | + if ( WP_FS__MODULE_TYPE_THEME !== $module_type ) { | |
| 345 | + $is_active = is_plugin_active( $data->file ); | |
| 346 | + } else { | |
| 245 | 347 | $current_theme = wp_get_theme(); |
| 246 | 348 | $is_active = ( $current_theme->stylesheet === $data->file ); |
| 247 | - } else { | |
| 248 | - $is_active = is_plugin_active( $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 | + } | |
| 249 | 355 | } |
| 250 | 356 | ?> |
| 251 | - <?php $fs = $is_active ? freemius( $data->id ) : null ?> | |
| 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 | + ?> | |
| 252 | 365 | <tr<?php if ( $is_active ) { |
| 253 | - if ( $fs->has_api_connectivity() && $fs->is_on() ) { | |
| 366 | + $has_api_connectivity = $fs->has_api_connectivity(); | |
| 367 | + | |
| 368 | + if ( true === $has_api_connectivity && $fs->is_on() ) { | |
| 254 | 369 | echo ' style="background: #E6FFE6; font-weight: bold"'; |
| 255 | 370 | } else { |
| 256 | 371 | echo ' style="background: #ffd0d0; font-weight: bold"'; |
| 257 | 372 | } |
| @@ -259,14 +374,16 @@ | ||
| 259 | 374 | <td><?php echo $data->id ?></td> |
| 260 | 375 | <td><?php echo $slug ?></td> |
| 261 | 376 | <td><?php echo $data->version ?></td> |
| 262 | 377 | <td><?php echo $data->title ?></td> |
| 263 | - <td<?php if ( $is_active && ! $fs->has_api_connectivity() ) { | |
| 378 | + <td<?php if ( $is_active && true !== $has_api_connectivity ) { | |
| 264 | 379 | echo ' style="color: red; text-transform: uppercase;"'; |
| 265 | 380 | } ?>><?php if ( $is_active ) { |
| 266 | - echo esc_html( $fs->has_api_connectivity() ? | |
| 381 | + echo esc_html( true === $has_api_connectivity ? | |
| 267 | 382 | fs_text_x_inline( 'Connected', 'as connection was successful' ) : |
| 268 | - fs_text_x_inline( 'Blocked', 'as connection blocked' ) | |
| 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' ) ) | |
| 269 | 386 | ); |
| 270 | 387 | } ?></td> |
| 271 | 388 | <td<?php if ( $is_active && ! $fs->is_on() ) { |
| 272 | 389 | echo ' style="color: red; text-transform: uppercase;"'; |
| @@ -277,12 +394,19 @@ | ||
| 277 | 394 | ); |
| 278 | 395 | } ?></td> |
| 279 | 396 | <td><?php echo $data->file ?></td> |
| 280 | 397 | <td><?php echo $data->public_key ?></td> |
| 281 | - <?php if ( is_multisite() ) : ?> | |
| 282 | - <?php $network_blog_id = $fs->get_network_install_blog_id() ?> | |
| 283 | - <?php $network_user = $fs->get_network_user() ?> | |
| 284 | - <td><?php echo is_numeric($network_blog_id) ? $network_blog_id : '' ?></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> | |
| 285 | 409 | <td><?php if ( is_object( $network_user ) ) { |
| 286 | 410 | echo $network_user->email; |
| 287 | 411 | } ?></td> |
| 288 | 412 | <?php endif ?> |
| @@ -293,9 +417,9 @@ | ||
| 293 | 417 | <input type="hidden" name="fs_action" value="simulate_trial"> |
| 294 | 418 | <input type="hidden" name="module_id" value="<?php echo $fs->get_id() ?>"> |
| 295 | 419 | <?php wp_nonce_field( 'simulate_trial' ) ?> |
| 296 | 420 | |
| 297 | - <button type="submit" class="button button-primary simulate-trial"><?php fs_esc_html_echo_inline( 'Simulate Trial' ) ?></button> | |
| 421 | + <button type="submit" class="button button-primary simulate-trial"><?php fs_esc_html_echo_inline( 'Simulate Trial Promotion' ) ?></button> | |
| 298 | 422 | </form> |
| 299 | 423 | <?php endif ?> |
| 300 | 424 | <?php if ( $fs->is_registered() ) : ?> |
| 301 | 425 | <a class="button" href="<?php echo $fs->get_account_url() ?>"><?php fs_esc_html_echo_inline( 'Account', 'account' ) ?></a> |
| @@ -324,11 +448,9 @@ | ||
| 324 | 448 | * @var array[string]FS_Site|array[string]FS_Site[] $sites_map |
| 325 | 449 | */ |
| 326 | 450 | $sites_map = $VARS[ $module_type . '_sites' ]; |
| 327 | 451 | |
| 328 | - $is_multisite = is_multisite(); | |
| 329 | - $all_plans = false; | |
| 330 | - $plans = false; | |
| 452 | + $all_plans = false; | |
| 331 | 453 | ?> |
| 332 | 454 | <?php if ( is_array( $sites_map ) && count( $sites_map ) > 0 ) : ?> |
| 333 | 455 | <h2><?php echo esc_html( sprintf( |
| 334 | 456 | /* translators: %s: 'plugin' or 'theme' */ |
| @@ -344,8 +466,9 @@ | ||
| 344 | 466 | <th><?php fs_esc_html_echo_inline( 'Address' ) ?></th> |
| 345 | 467 | <?php endif ?> |
| 346 | 468 | <th><?php fs_esc_html_echo_inline( 'Slug' ) ?></th> |
| 347 | 469 | <th><?php fs_esc_html_echo_inline( 'User ID' ) ?></th> |
| 470 | + <th><?php fs_esc_html_echo_inline( 'License ID' ) ?></th> | |
| 348 | 471 | <th><?php fs_esc_html_echo_x_inline( 'Plan', 'as product pricing plan', 'plan' ) ?></th> |
| 349 | 472 | <th><?php fs_esc_html_echo_inline( 'Public Key' ) ?></th> |
| 350 | 473 | <th><?php fs_esc_html_echo_inline( 'Secret Key' ) ?></th> |
| 351 | 474 | <th><?php fs_esc_html_echo_inline( 'Actions' ) ?></th> |
| @@ -351,21 +474,44 @@ | ||
| 351 | 474 | <th><?php fs_esc_html_echo_inline( 'Actions' ) ?></th> |
| 352 | 475 | </tr> |
| 353 | 476 | </thead> |
| 354 | 477 | <tbody> |
| 478 | + <?php $site_url = null ?> | |
| 355 | 479 | <?php foreach ( $sites_map as $slug => $sites ) : ?> |
| 356 | - <?php if ( ! is_array( $sites ) ) { | |
| 357 | - $sites = array( $sites ); | |
| 358 | - } ?> | |
| 359 | 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 | + ?> | |
| 360 | 500 | <tr> |
| 361 | - <td><?php echo $site->id ?></td> | |
| 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> | |
| 362 | 507 | <?php if ( $is_multisite ) : ?> |
| 363 | - <td><?php echo $site->blog_id ?></td> | |
| 508 | + <td><?php echo $blog_id ?></td> | |
| 364 | 509 | <td><?php echo fs_strip_url_protocol( $site->url ) ?></td> |
| 365 | 510 | <?php endif ?> |
| 366 | 511 | <td><?php echo $slug ?></td> |
| 367 | 512 | <td><?php echo $site->user_id ?></td> |
| 513 | + <td><?php echo !empty($site->license_id) ? $site->license_id : '' ?></td> | |
| 368 | 514 | <td><?php |
| 369 | 515 | $plan_name = ''; |
| 370 | 516 | if ( FS_Plugin_Plan::is_valid_id( $site->plan_id ) ) { |
| 371 | 517 | if ( false === $all_plans ) { |
| @@ -373,16 +519,12 @@ | ||
| 373 | 519 | if ( WP_FS__MODULE_TYPE_PLUGIN !== $module_type ) { |
| 374 | 520 | $option_name = $module_type . '_' . $option_name; |
| 375 | 521 | } |
| 376 | 522 | |
| 377 | - $all_plans = $fs_options->get_option( $option_name, array() ); | |
| 523 | + $all_plans = fs_get_entities( $fs_options->get_option( $option_name, array() ), FS_Plugin_Plan::get_class_name() ); | |
| 378 | 524 | } |
| 379 | 525 | |
| 380 | - if ( false === $plans ) { | |
| 381 | - $plans = $all_plans[ $slug ]; | |
| 382 | - } | |
| 383 | - | |
| 384 | - foreach ( $plans as $plan ) { | |
| 526 | + foreach ( $all_plans[ $slug ] as $plan ) { | |
| 385 | 527 | $plan_id = Freemius::_decrypt( $plan->id ); |
| 386 | 528 | |
| 387 | 529 | if ( $site->plan_id == $plan_id ) { |
| 388 | 530 | $plan_name = Freemius::_decrypt( $plan->name ); |
| @@ -393,9 +535,15 @@ | ||
| 393 | 535 | |
| 394 | 536 | echo $plan_name; |
| 395 | 537 | ?></td> |
| 396 | 538 | <td><?php echo $site->public_key ?></td> |
| 397 | - <td><?php echo esc_html( $site->secret_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> | |
| 398 | 546 | <td> |
| 399 | 547 | <form action="" method="POST"> |
| 400 | 548 | <input type="hidden" name="fs_action" value="delete_install"> |
| 401 | 549 | <?php wp_nonce_field( 'delete_install' ) ?> |
| @@ -400,9 +548,9 @@ | ||
| 400 | 548 | <input type="hidden" name="fs_action" value="delete_install"> |
| 401 | 549 | <?php wp_nonce_field( 'delete_install' ) ?> |
| 402 | 550 | <input type="hidden" name="module_id" value="<?php echo $site->plugin_id ?>"> |
| 403 | 551 | <?php if ( $is_multisite ) : ?> |
| 404 | - <input type="hidden" name="blog_id" value="<?php echo $site->blog_id ?>"> | |
| 552 | + <input type="hidden" name="blog_id" value="<?php echo $site->blog_id ?>"> | |
| 405 | 553 | <?php endif ?> |
| 406 | 554 | <input type="hidden" name="module_type" value="<?php echo $module_type ?>"> |
| 407 | 555 | <input type="hidden" name="slug" value="<?php echo $slug ?>"> |
| 408 | 556 | <button type="submit" class="button"><?php fs_esc_html_echo_x_inline( 'Delete', 'verb', 'delete' ) ?></button> |
| @@ -452,9 +600,31 @@ | ||
| 452 | 600 | <?php |
| 453 | 601 | /** |
| 454 | 602 | * @var FS_User[] $users |
| 455 | 603 | */ |
| 456 | - $users = $VARS['users']; | |
| 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 | + | |
| 457 | 627 | ?> |
| 458 | 628 | <?php if ( is_array( $users ) && 0 < count( $users ) ) : ?> |
| 459 | 629 | <h2><?php fs_esc_html_echo_inline( 'Users' ) ?></h2> |
| 460 | 630 | <table id="fs_users" class="widefat"> |
| @@ -470,16 +640,22 @@ | ||
| 470 | 640 | </tr> |
| 471 | 641 | </thead> |
| 472 | 642 | <tbody> |
| 473 | 643 | <?php foreach ( $users as $user_id => $user ) : ?> |
| 644 | + <?php $has_developer_license = isset( $users_with_developer_license_by_id[ $user_id ] ) ?> | |
| 474 | 645 | <tr> |
| 475 | 646 | <td><?php echo $user->id ?></td> |
| 476 | - <td><?php echo $user->get_name() ?></td> | |
| 477 | - <td><a href="mailto:<?php echo esc_attr( $user->email ) ?>"><?php echo $user->email ?></a></td> | |
| 478 | - <td><?php echo json_encode( $user->is_verified ) ?></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> | |
| 479 | 654 | <td><?php echo $user->public_key ?></td> |
| 480 | - <td><?php echo esc_html( $user->secret_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> | |
| 481 | 656 | <td> |
| 657 | + <?php if ( ! $has_developer_license ) : ?> | |
| 482 | 658 | <form action="" method="POST"> |
| 483 | 659 | <input type="hidden" name="fs_action" value="delete_user"> |
| 484 | 660 | <?php wp_nonce_field( 'delete_user' ) ?> |
| 485 | 661 | <input type="hidden" name="user_id" value="<?php echo $user->id ?>"> |
| @@ -484,8 +660,9 @@ | ||
| 484 | 660 | <?php wp_nonce_field( 'delete_user' ) ?> |
| 485 | 661 | <input type="hidden" name="user_id" value="<?php echo $user->id ?>"> |
| 486 | 662 | <button type="submit" class="button"><?php fs_esc_html_echo_x_inline( 'Delete', 'verb', 'delete' ) ?></button> |
| 487 | 663 | </form> |
| 664 | + <?php endif ?> | |
| 488 | 665 | </td> |
| 489 | 666 | </tr> |
| 490 | 667 | <?php endforeach ?> |
| 491 | 668 | </tbody> |
| @@ -491,9 +668,13 @@ | ||
| 491 | 668 | </tbody> |
| 492 | 669 | </table> |
| 493 | 670 | <?php endif ?> |
| 494 | 671 | <?php foreach ( $module_types as $module_type ) : ?> |
| 495 | - <?php $licenses = $VARS[ $module_type . '_licenses' ] ?> | |
| 672 | + <?php | |
| 673 | + /** | |
| 674 | + * @var FS_Plugin_License[] $licenses | |
| 675 | + */ | |
| 676 | + $licenses = $VARS[ $module_type . '_licenses' ] ?> | |
| 496 | 677 | <?php if ( is_array( $licenses ) && count( $licenses ) > 0 ) : ?> |
| 497 | 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> |
| 498 | 679 | <table id="fs_<?php echo $module_type ?>_licenses" class="widefat"> |
| 499 | 680 | <thead> |
| @@ -504,8 +685,9 @@ | ||
| 504 | 685 | <th><?php fs_esc_html_echo_inline( 'Plan ID' ) ?></th> |
| 505 | 686 | <th><?php fs_esc_html_echo_inline( 'Quota' ) ?></th> |
| 506 | 687 | <th><?php fs_esc_html_echo_inline( 'Activated' ) ?></th> |
| 507 | 688 | <th><?php fs_esc_html_echo_inline( 'Blocking' ) ?></th> |
| 689 | + <th><?php fs_esc_html_echo_inline( 'Type' ) ?></th> | |
| 508 | 690 | <th><?php fs_esc_html_echo_inline( 'License Key' ) ?></th> |
| 509 | 691 | <th><?php fs_esc_html_echo_x_inline( 'Expiration', 'as expiration date' ) ?></th> |
| 510 | 692 | </tr> |
| 511 | 693 | </thead> |
| @@ -518,9 +700,14 @@ | ||
| 518 | 700 | <td><?php echo $license->plan_id ?></td> |
| 519 | 701 | <td><?php echo $license->is_unlimited() ? 'Unlimited' : ( $license->is_single_site() ? 'Single Site' : $license->quota ) ?></td> |
| 520 | 702 | <td><?php echo $license->activated ?></td> |
| 521 | 703 | <td><?php echo $license->is_block_features ? 'Blocking' : 'Flexible' ?></td> |
| 522 | - <td><?php echo esc_html( $license->secret_key ) ?></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> | |
| 523 | 710 | <td><?php echo $license->expiration ?></td> |
| 524 | 711 | </tr> |
| 525 | 712 | <?php endforeach ?> |
| 526 | 713 | </tbody> |
| @@ -663,10 +850,12 @@ | ||
| 663 | 850 | |
| 664 | 851 | offset = 0; |
| 665 | 852 | } |
| 666 | 853 | |
| 667 | - $.post(ajaxurl, { | |
| 854 | + $.post(<?php echo Freemius::ajax_url() ?>, { | |
| 668 | 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' ) ); ?>, | |
| 669 | 858 | filters: filters, |
| 670 | 859 | offset : offset, |
| 671 | 860 | limit : limit |
| 672 | 861 | }, function (response) { |