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