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